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

Create a New Response API and Embedded Data

  • December 6, 2024
  • 3 replies
  • 107 views

Forum|alt.badge.img+2

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)?

Best answer by ppuente

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": "example@example.com",
    "Order Line Items": [
      "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 :) 

View original

Aggarwal
Level 4 ●●●●
Forum|alt.badge.img+15
  • Level 4 ●●●●
  • January 4, 2025

Your request body should look like:

 

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


Forum|alt.badge.img+6
  • QPN Level 2 ●●
  • January 4, 2025

@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)


Forum|alt.badge.img+2
  • January 9, 2025

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": "example@example.com",
    "Order Line Items": [
      "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