Create assignments using api

Dear all,

I am studying the api to create assignment at https://demo.mysurvey.solutions/apidocs/index#!/Assignments/Assignments_Create. I was able to figure out the correct way to create assignment with single-select questions pre-filled. However, I cannot figure a way to pre-fill multi-select questions.

Suppose that there is a multi-select question with variable name “fruit”, and three options: 1 for apple, 2 for pear, and 3 for banana. Suppose I want to create an assignment with the first and third option (ie. apple and banana) of the fruit question been selected. I have tried the following code:

{
“Responsible”: “83d98687-cf8e-42b7-9309-47a50cd87165”,
“Quantity”: 1,
“QuestionnaireId”: “762dc010-f4e6-430c-a498-5fc2c3dba38c$1”,
“IdentifyingData”: [
{
“Identity”: “”,
“Variable”: “fruit”,
“Answer”: “[1, 3]”
}
]
}

The server returned a 400 error message with the following message:

Answer ‘[1, 3]’ canot be parsed for question with Identity ‘’ and variable ‘fruit’.\r\nUnable to cast object of type ‘System.String’ to type ‘Newtonsoft.Json.Linq.JArray’.

Can anyone share any ideas?

Thanks.

Peng

By the way, I am using version 18.08.

Not all questions can be prefilled, multiple choice question is the one that cannot be prefilled.
For the reference you can check the documentation