Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The FAQs provide some examples and code snippets for common tasks when a third-party application wants to interact with the server.

On this page:

Table of Contents
maxLevel1

How do I login and logout to and from a server?

See the The FAQs provide some examples and code snippets for common tasks when a third-party application wants to interact with the server.

On this page:

Table of Contents
maxLevel1

How do I login and logout to and from a server?

See the Java code snippet below:

Code Block
    FormsService fs = new FormsService("localhost", 8082);
    fs.login("myuserid", "mypassword");

    // interact with frevvo

    fs.logout();

...

Code Block
/ formTypeID of your form. You can get the formTypeId of a form by looking at its Share URL. For example, if your forms Raw URL is: http://localhost:8082/frevvo/web/tn/qa/user/fd/app/_S5QyQQ8GEeKoZPV3UpCRog/formtype/_W03sMA8GEeKoZPV3UpCRog?_method=post&embed=true&locale=, then the part of this URL between formtype/ and ?_method is your formTypeId.
String formTypeId = "_W03sMA8GEeKoZPV3UpCRog";  

// Get the Forms Service.
FormsService service = new FormsService("http", "localhost", 8082, null);
service.login("designer@tutorial", "designerpswd");

// Get Submission Feed
SubmissionQuery q = new SubmissionQuery(service.getFeedURL(SubmissionFeed.class));
q.setFilter("$formTypeId eq " + formTypeId);
q.setOrderby("$updated");  
SubmissionFeed sFeed = service.getFeed(q, SubmissionFeed.class);

int counter = 1;
// Download PDF for each submission
for (SubmissionEntry contact : sFeed.getEntries()) {
       // re-instantiate the form from the submission
       URL fUrl = contact.createFormInstance(null, null);
       // Construct the URL which will generate the PDF
       String pdfUrl = fUrl.toString() + "&print=true&format=pdf";
       String filename = "E:\\myFormPDF" + counter + ".PDF";
       BufferedInputStream in = null;
       FileOutputStream fout = null;
       try
       {
             in = new BufferedInputStream(new URL(pdfUrl).openStream());
             fout = new FileOutputStream(filename);

             byte data[] = new byte[1024];
             int count;
             while ((count = in.read(data, 0, 1024)) != -1)
             {
                    fout.write(data, 0, count);
             }
       }
       finally
       {
             if (in != null)
                    in.close();
             if (fout != null)
                    fout.close();
       }      
       counter ++;
 counter ++;
       // Cancel the instance
       Helper.cancelInstance(service, fUrl);    
}

How do I batch upload users from the api?

Note

The format of the users csv file is the same as that used through the UI users load feature.

Users csv upload is through HTTP.  

The users csv upload is available directly through HTTP. One way to do this is using cURL, but other ways are possible. Here are the steps:

...

code
       // Cancel the instance
       Helper.cancelInstance(service, fUrl);    
}

How do I batch upload users from the api?

Note

The format of the users csv file is the same as that used through the UI users load feature.

Users csv upload is through HTTP.  

The users csv upload is available directly through HTTP. One way to do this is using cURL, but other ways are possible. If you are running these command on Windows, make sure you open the Command Prompt using the ‘Run as administrator’ option.

Here are the steps:

  1. Log in:

Code Block
curl http://host:port/frevvo/web/login -d username=admin@tenant -d password=admin_password -d lAction=Login  -X POST  -c cookies -H Content-Type:application/x-www-form-urlencoded  

      2. Replace host, port, username and password above as correct for your implementation. For  online, host=app.frevvo.com and the port is optional. Change http to https.

Info

If your tenant is on the frevvo cloud server, and you see the error "Couldn't open file "users.csv", perform one of the following actions:

  • Update the trusted certificate authorities present on your client machine
  • Disable the certificate check with the cURL -k option:

 

curl http://host:port/frevvo/web/login -d username=admin@tenant -d password=admin_password -d lAction=Login  -X POST  -c cookies -H Content-Type:application/x-www-form-urlencoded  

...

-k 

      3. Upload the users csv file:  

Code Block
curl http://host:port/frevvo/web/tn/tenant.id/allUsers  -F notificationEmailAddress=some_email_address -F usersFile=@users_file.csv  -X POST  -b cookies -H Content-Type:multipart/form-data

      4. Replace host, port, tenant.id, some_email_address and users_file.csv above as correct for your implementation. If users_file.csv is not in the current directory, adjust the path accordingly. For Live forms online, host=app.frevvo.com and port is optional. Change http to https.

...

Code Block
curl http://host:port/frevvo/web/tn/tenant.id/allUsers  -X GET  -b cookies

...

For Live forms online, host=app.frevvo.com and port is optional. Change http to https and add the -k option

Code Block
curl http://host:port/frevvo/web/tn/tenant.id/allUsers  -X GET  -b cookies -k

7. The response will be the users csv data.

Users csv upload through the Java data api

...

You can specify who receives an email reporting the upload status when it is done through the API. The email is sent to the "notificationEmailAddress" that is passed in the API. The email may say something like this if there are errors during the upload:

Code Block
Validation occurred with errors. Users data NOT loaded. Refer to attached CSV data file for validation and/or loading result details.

...