Create a New Response API and Embedded Data | XM Community
Skip to main content

I want to call the Create a New Response API to create survey responses from my application (https://api.qualtrics.com/f1cad92018d2b-create-a-new-response). I don’t see a way to add embedded data to that request. Is there a way to create add embedded data with a survey response creation request, or am I required to send a subsequent Update Response request (https://api.qualtrics.com/daed82306b1ea-update-response)?

Your request body should look like:

 

{
  "values": {
    "questionId1": "response1",
    "questionId2": "response2"
  },
  "embeddedData": {
    "key1": "value1",
    "key2": "value2"
  }
}


@ppuente ,

you can add embedded data either 

1)In the Update Response API, you can include the embedded data in the request body like this:
 

{
"embeddedData": {
"Key1": "Value1",
"Key2": "Value2"
}
}

2)Set embedded data before survey completion in survey flow (No APIs)


I found a way to do it by inspecting the response from the Retrieve a Survey Response API. I am able to add additional keys to the values object in my Create a Survey Response request.

 

For example, this request body creates a new response with answers to questions but no embedded data:

{

  "values": {

    "QID2": 2,

    "QID22": "test",

    "QID25": 3,

    "QID26": 3,

    "QID28": 1,

    "QID29": 3,

    "QID30": 2,

  }

}

This request body also adds embedded data:


{
"values": {
"QID2": 2,
"QID22": "test",
"QID25": 3,
"QID26": 3,
"QID28": 1,
"QID29": 3,
"QID30": 2,
"Email": "[email protected]",
"Order Line Items": r
"Product Name"
],
"Order Value": 4.9
}
}

This request body answered the questions and provided the embedded data. The key names for the embedded data appear to match the name of each object in the result.embeddedData object in the response from the Get Survey CRUD API. No second request required :) 


Leave a Reply


OSZAR »