Saves the provided answers for the questionary of the specified shop.
This set of answers will be used to prefill the questionary in the next generation.
If the answers satisfy all questions in the questionary, then, from this point on, this set of answers
will also be used to generate the documents for this shop.
Note
The answers that you send to this endpoint are saved as a completely new set of answers.
Any previously saved answers will not be used and are not merged with these answers.
So, in other words, these values replace the existing answers.
If you want to re-use the values you have already saved,
Retrieve the latest answers via the latestAnswers endpoint,
merge manually the values you need from the old answers with your new answers
and send the merged state instead. Check the example below (Reusing existing answers) for more details.
Example answers array:
answers[conditions][c1001]: 1
answers[conditions][c1002]: 1
answers[conditions][c1003]: 0
answers[conditions][c1004]: 1
answers[variables][v1001]: "Var 1"
answers[variables][v1002]: "Var 2"
answers[variables][v1003]: "Var 3"
answers[variables][v1004]: "Var 4"
Example responses:
// Complete Answers
{
"shopId":"6C8CF85DDDF79FE4493AB018AD375A7C",
"content":true, // deprecated (replaced by "success")
"success":true, // If answers were saved
"answersStatus": {
// If the saved answers are valid
"valid": true,
// Explanation of why the answers are marked invalid
"errorMsg": "",
// incomplete|incorrect - we can not generate documents from these answers
// but they were saved to be finished later
"errorType": ""
}
}
// Incomplete Answers (some of the answers have not been provided)
// Answers are saved so the rest of the answers can be privided later
{
"shopId":"6C8CF85DDDF79FE4493AB018AD375A7C",
"content":true, // deprecated (replaced by "success")
"success":true, // If answers were saved
"answersStatus": {
"valid": false,
"errorMsg": "Variable 'v2345' is missing",
"errorType": "incomplete"
}
}
// Wrong Answers
// Some of the answers do not follow the questionary rules
// If you recieved response like this, the answers you supplied were not saved
// You need to fix the problem explained in 'errorMsg' and make the request again
{
"shopId":"6C8CF85DDDF79FE4493AB018AD375A7C",
"content":true, // deprecated (replaced by "success")
"success":false, // If answers were saved
"answersStatus": {
"valid": true,
"errorMsg": "'opt0' is not an allowed option for radio variable 'v2345' (Allowed: opt1,opt2,opt3)",
"errorType": "incorrect"
}
}
Answers for Radio and Checkbox questions
Conditions in Radio and Checkbox questions have the following rules:
- Exactly one condition in a radio question has to be true.
- One or more conditions in a checkbox question have to be true.
You are allowed to send just some of the values for onditions in these quesitons
and the rest of the conditions in the question will be set to false.
For example if a radio question consists of c1001, c1002, c1003 and c1004,
and you send this set of answers:
answers[conditions][c1001]: 1
our system will handle it automatically and the following answers will be stored:
answers[conditions][c1001]: 1
answers[conditions][c1002]: 0
answers[conditions][c1003]: 0
answers[conditions][c1004]: 0
The same applies for checkbox questions.
Example: Reusing existing answers
First, we need to retrieve some exisiting answers from the system.
You can you the answers list to select which answers set you want and then retrieve it by id.
However, we recommend using the latestAnswers endpoint, which will pick the correct set of answers automatically.
Lets say the endpoint returns the following previously saved answers:
{
"conditions": {
"c1101": "0",
"c1102": "0"
},
"variables": {
"v1001": "Company name"
}
}
We want to save c2000 with value "1". If we just save its value, in the latest answers we would have only its value.
So we merge c2000=1 with the array returned by the latestAnswers endpoint.
After merging c2000 in the conditions part of the answers, we have:
{
"conditions": {
"c1101": "0",
"c1102": "0",
"c2000": "1"
},
"variables": {
"v1001": "Company name"
}
}
We save these answers instead of just {"conditions": {"c2000": "1"}, "variables": {}}
.
In this way we have preserved the previous state of the answers and have added our new values to them.
Ofcource, sometimes you dont want to preserve all values. In this case just unset the unneeded values
from the answers before sending them.