About Web Services
Sometimes you may want to include more complex features in your survey. Maybe you want to pull in the top 10 headlines from a news website into your survey, or you want to automate a second survey distribution to be emailed to the respondents of a first survey exactly two hours later. A Web Service would allow you to do just that by making requests to a designated URL.
Adding a Web Service
- While editing your survey, click the Survey flow icon in the left navigation bar.
- Click Add Below or Add a New Element Here.
- Select Web Service.
- In the URL field, paste the URL of your external Web Service.
- Select a Method for your web service. We will explain more about the different methods in the section below.
Our web service feature allows you to choose from a series of Methods to request information from your specified URL.
|GET||The web service goes to the URL and retrieves information.||Retrieve information about a member of your contact list. See the Get Contact API call for more details.|
|POST||Go to the URL and save information there.||Save a message to your library.|
|PUT||Update or replace existing information.||Change a username. This is one of the things you can do with the Update User call.|
|PATCH||Update or replace existing information. Very similar to PUT. While our web Service offers this method, our API does not use PATCH calls.||Modify data saved on your server.|
|DELETE||Remove information.||Delete a graphic from your library.|
If you are using our API calls, the documentation will tell you which method to use, as indicated in the screenshot below.
There are currently three types of Parameters you can append to your request.
- Query parameter: Instead of adding a query string to the end of your Web Service URL, place your query parameters here.
- Body parameter: This parameter is not available for GET or DELETE requests. It comes with two formatting options:
a) application/x-www-form-urlencoded: Rather than entering your body parameters into the specified area of the Web Service, add them as a query string at the end of your specified URL.
b) application/json: Enter your keys in Dot Notation. For example, our API call may ask you to specify a header[fromEmail]. In Dot Notation, this becomes header.fromEmail.
- Custom header: Insert URL headers here.
If you’re using our API calls, the documentation will tell you what kind of parameters to include. The example below provides Body parameters to set.
Adding Parameters to Your Web Service
- Select any of the three Add a parameter to send to web service options indicated in the previous section. In the above example, we are indicating the Query Parameters.
- Type in the name of the parameter in the Parameter to Web Service box on the left.
- Type the corresponding value of the parameter in the Value box on the right.
- Click the plus (+) sign to the right of the parameter to add another.
- Click Apply when finished.
Testing Your Parameters
Once you have pasted in your URL and set up your parameters, you can test your URL to see what Fields you can pull in.
- Click Test URL to see which information you can pull from the external Web Service.
- Select any fields that you want to use or record in your survey. The Field Name appears on the left and a corresponding Example Value appears on the right.
- Click Add Embedded Data to add selected fields to your data.
Qtip: You can change the embedded data names associated with the fields of your web service under the Set Embedded Data column. The embedded data names are to the left of the equals (=) sign, indicated by a green ED icon. The right side should not be altered. The names you set on the left will be the names of the fields as they appear in your data.
- If you select Fire and Forget, you will not save any of the data returned from the web service call. This feature is useful when you do not need to save the returned data.
Qtip: Fire and Forget allows your survey to make a request to a web service without waiting for a response. This means that your respondents will be able to complete the full survey without any delay due to the web service. You may want to use this option if you have a web service request that takes a while to process, but we would recommend that you only use this feature during testing, since it will prevent embedded data from saving.
- When you’re done, click Apply.
Correcting TLS Errors
As of September 1, 2021, web service requests with Transport-Layer Security (TLS) errors will fail. TLS is what makes web requests over HTTPS (as opposed to plain HTTP) secure, preventing the request data from being visible to third parties and ensuring that the request is sent to the correct destination. Ignoring TLS errors effectively eliminates these security benefits; this change is an important step in our continual efforts to improve the security of the Qualtrics platform.
In order to resolve each TLS error, you need to do one of the following:
- Fix the TLS error. Due to the nature of TLS errors, our support team cannot provide specific guidance on how to do so, but your network administrator will know how to fix the error.
- Change the flow element web service request to be made over HTTP, not HTTPS. For example, you could change the URL “https://example.com” to “http://example.com”. If you choose to take this approach, you should also ensure that the HTTP URL doesn’t redirect to the HTTPS URL.
Attention: Please note that this approach will cause the web service request data to be transmitted unencrypted.
You can verify that your web service element is ready for this change by using the test button next to the URL field in the flow element. Viewing the raw data in the resulting window, also shown below, should not show an error.
Random Number Generator
Back when Qualtrics was first getting started, we encouraged users to use a web service calling a random number generator to create IDs for survey respondents. However, based on feedback, we found that this process can be long, difficult, and painful.
There are now much easier ways to generate random numbers for your respondents using piped text. For even more support setting up your randomized IDs and displaying them to respondents, see the assigning random IDs to respondents page.