How-To: Integrate ProntoForms with SQL Server with the REST API

Note:  This article refers specifically to integration with Microsoft SQL Server®.  Though some details may differ,  the same general approach can be applied to integration with other relational database systems like Oracle, MySQL, PostgreSQL, or IBM DB2. 



What does this article provide? We’ll be showing what is needed to integrate to and from ProntoForms and SQL Server®. A couple items you will need before you begin:

    1. Basic programming knowledge.
    2. Microsoft SQL Server® knowledge (we will not be going in to how to install or maintain SQL Server®).
    3. Understanding of how REST API’s work.
    4. General ETL knowledge.
    5. You will need a SQL server up and functioning.

We’ll show two distinct integration cases; the first will be how to dispatch data from a table to ProntoForms. This means how to send data to a ProntoForms device through the dispatching API. The second is how to get ProntoForms data to an SQL table.

[ top ]


Dispatching Data from SQL Server® to ProntoForms

1. Choose the table from the SQL server you want to dispatch data from.  1.png    
2.  You will most likely need some form of connection to your SQL server.  Typically this is an ODBC connection.  You can export your information from the table from SQL Server Management Studio® if needed. 
RETCODE retcode;
UCHAR *szDriver = "SQL Server";
UCHAR *szAttributes = "DSN=my65dsn\0DESCRIPTION=SQLConfigDSN Sample\0"
retcode = SQLConfigDataSource(NULL,


  How to export from SQL Server®

3. Once you can connect to your database and obtain information from the table, you will need to format it in a way in which makes sense for your form. You will need to know the ProntoForms schema for dispatching information to the ProntoForms backend.  This information can be found on their REST API documentation page.   XML
     <answer label="firstName">John</answer>
     <answer label="lastName">Smith</answer>


 "formId": "140001",
 "username": "bjohnston",
 "data": [
       "label": "colors",
       "answer": "grey"
       "label": "colors",
       "answer": "blue"   
4. Before you can make any REST API calls to ProntoForms you will need to setup an application to do so.  Detailed information on that can be found on the ProntoForms page.   Setup an API Application
5. Now that you have everything in place you will need to make a REST API call with the dispatch information.  Based on the type of data you selected, either XML or JSON you will need to point to the correct URL, Dispatch.xml or Dispatch.json and POST your data to the server.
// Upload a file to an HTTP server.
pplx::task<void> UploadFileToHttpServerAsync()
{ using concurrency::streams::file_stream;
using concurrency::streams::basic_istream;
// To run this example, you must have a file named myfile.txt
in the current folder.
// Alternatively, you can use the following code to create a stream
from a text string.
// std::string s("abcdefg");
// auto ss = concurrency::streams::stringstream::open_istream(s);
// Open stream to file. return file_stream<unsigned
basic_istream<unsigned char> previousTask)
auto fileStream = previousTask.get();
// Make HTTP request with the file stream as the body.
http_client client(L"");
return client.request(methods::PUT, L"myfile", fileStream).then
std::wostringstream ss;
auto response = previousTask.get();
ss << L"Server returned returned status code " <<
response.status_code() << L"." << std::endl;
catch (const http_exception& e)
ss << e.what() << std::endl;
std::wcout << ss.str();
catch (const std::system_error& e)
std::wostringstream ss;
ss << e.what() << std::endl;
std::wcout << ss.str();
// Return an empty task.
return pplx::task_from_result();
/* Sample output:
The request must be resent
*/ }
6. Detailed information on REST API calls from Windows® can be found here.  REST API CALLS
7.  Once the dispatch call has taken place you will receive a response from the server on the status of the call.  This allows you to deal with how the call went or have access to the dispatched data if from ProntoForms.




  "dataId": "123",
  "referenceNumber": "20110902-123"

[ top ]


Retrieving ProntoForms Data and Integrating with SQL Server®


As with dispatching data from SQL Server®, you will need to have an application setup in ProntoForms to talk to the REST API on your account. Setup an Application


You will then need to identify which form you would like to get data for.  Specifically you will need the form id which can be found here.




This time you will want to make a REST API GET Call from ProntoForms in the specific format you would like receive the data in.
// Builds an HTTP request that uses custom header values.
pplx::task<void> HTTPRequestCustomHeadersAsync()
{     http_client client(L"");

    // Manually build up an HTTP request with header and request URI.
    http_request request(methods::GET);     request.headers().add(L"MyHeaderField", L"MyHeaderValue");
    return client.request(request).then([](http_response response)
    {         // Print the status code.
        std::wostringstream ss;
        ss << L"Server returned returned status code " <<
response.status_code() << L"." << std::endl;
        std::wcout << ss.str();

    /* Sample output:
    Server returned returned status code 200.


First you will need to get listing of records for this form.  These items are request parameters for the API call which you will want to put in the form information.

Request Parameters



Default Value





 0-based page number.




 Number of results in the page.  The maximum value is 100.




 Time zone to present all dates in.




 Lower-bound limit on the Server Receive Date of Data Records




 Upper-bound limit on the Server Receive Date of Data Records




 Comma-separated set of FormSpace Identifiers the Data Records belong to




 Comma-separated set of Form Identifiers the Data Records belong to




 Comma-separated set of Group Identifiers the Data Records must have been submitted by




 Comma-separated set of user Identifiers the Data Records must have been submitted by




 Comma-separated set of Usernames the Data Records must have been submitted by



The data will be returned to you in the format specified from the call.


<pagedList totalNumberOfResults="1">
   <dataRecord identifier="123">


  "totalNumberOfResults": 1,
  "zone": "America/New_York",
  "pageData": [{
    "identifier": "123",
    "referenceNumber": "20110911-123",
    "state": "Complete",
    "actionState": "Processing",
    "dataPersisted": true,
    "serverReceiveDate": "2011-09-30T18:20:46-05:00",
    "formVersionId": "345",
    "formId": "234",
    "userId": "123",
    "username": "uname"
6. Now that you have all the records listed you will need to get individual record data for the form.  This is another REST API call, this will be a GET call.  You need to loop through the list and call this for each data record id.  URL Structure[version]/data/[id].xml[version]/data/[id].json[version]/data/[id].pdf[version]/data/[id].doc[version]/data/[id].html
7. As you receive each piece of data from ProntoForms you will need to modify it in a way which makes sense for the table you are importing into.  
8. Again, use a connection method to SQL Server to insert the data in to the table.  

[ top ]


*SQL Server® is a registered trademark of Microsoft®.  ProntoForms is not affiliated with, nor has this article been authorized, endorsed or otherwise approved by Microsoft Corporation.

Was this article helpful?
2 out of 2 found this helpful
Have more questions? Submit a request