Update Sample Fields API
Allows users to update respondent sample fields via API.
Request information
method="POST"
must be done over https
POST URL format: https://<branded_instance>/reactor-webapp/pt/<project_name>/pn/lumicompass/api/update_sample_fields
URL parameters
<branded_instance>
The first word of your Dashboard URL, e.g. "dashboard"
<project_name>
You can find this at the top right corner of your dashboard, please note this field is case sensitive
Parameters
|
Name |
Value |
Description |
|
user_name |
String |
A valid backend user's credentials |
|
password |
String |
A valid backend user's credentials |
|
respondents_json |
String |
A JSON String containing the participant data. See below. |
JSON Format
Example Json:
JSON example
|
{"company_id":"","respondents":[ {"username":"","sample_fields":[{"alias":"","value":""},{"alias":"","value":""}]}, {"username":"","sample_fields":[{"alias":"","value":""}]}, {"username":"","sample_fields":[{"alias":"","value":""},{"alias":"","value":""}]} ... ]} |
|
Parameter |
Value |
Description |
Required |
|
company_id |
Integer |
The id of the company the respondents belong to. |
No, but the copy will fail if the user has access to more than one company if this variables isn't specified |
|
respondents |
Json Array |
Container for the respondent data |
Yes |
|
username |
String |
Respondent id/username |
Yes |
|
sample_fields |
Json Array |
Container for sample fields (only those in question) |
Yes |
|
alias |
String |
Alias of the sample field |
Yes |
|
value |
String |
Value of the sample field |
Yes |
Responses
HTTP error responses that are implemented
|
Response |
Message |
Reason |
|
HTTP 400 |
Action not supported |
Not a POST request |
|
HTTP 403 |
Not supported |
Not using HTTPS |
JSON responses are given if the request passes the initial validation (i.e. if the HTTP errors do not apply)
Format: {"message":"","status":""} JSON responses are given if the request passes the initial validation (i.e. if the HTTP errors do not apply)
Where message will contain a descriptive message string, and status is either "ok" if the upload succeeded or "error" if it failed.
|
Status |
Message |
Reason |
|
ok |
Sample field update completed successfully |
Success message. If any respondents from the json is not found, the ids are included in the message as well. If any of the values couldn't be parsed (for example when expecting a numeric value but a string is entered) will also be listed per user. Example: {"unable_to_parse_value":"[user:age, Myuser:age]","id":1459856038679,"message":"Sample field update completed successfully","status":"ok","respondents_unable_to_update":"[sample1...]"} |
|
error |
Error missing required parameter. |
One of user_name/password/respondents_json is missing. |
|
error |
Authentication failure. |
Failed to authenticate with given credentials. |
|
error |
Could not parse json parameter as a JSONObject. |
Parse error when parsing the respondents_json - not valid Json string |