API update responses (when a ticket is created) with a standalone workflow - bringing surveyID | XM Community
Skip to main content

There is a way to have a standalone workflow to update responses when a ticket is created (I don’t want to configure several workflows). I can do it easily when I manually input the survey ID.

I’m bringing the survey ID as ticket data, and I also tried to create an API to fetch that information, but it doesn’t work.

 

Hi,

Your piped in survey ID should probably be wrapped in quotes

"~{ch://OCAC...}"

 


Thanks. When I test the ticket, it works, but when I run it, it shows these errors.

 


Thanks. When I test the ticket, it works, but when I run it, it shows these errors.

 

@Susana_Branco Check the Input JSON to see if it’s getting the right ID from that first API. With the test, you decide the value so it just to confirm the API worked. It doesn’t mean that you get the right value when it’s running automatically

 

 

You only need 2 custom path here. 1 is for the survey ID value and 1 is for the response ID value, the rest you can just delete.
$.result.ticketData.elementsa2].value

$.result.ticketData.elementsa3].value

 

 

Now you can just use the {a} icon to precisely put data from previous task that you have custom path to this one. Remember survey ID it’s a JSON string so it have to be put in “”

{
"surveyId": "{a} in the previous task response ID",
"resetRecordedDate": true,
"embeddedData": {
"property1": "string",
"property2": "string"
}
}

Also the URL path

https://yul1.qualtrics.com/API/v3/responses/{a}_the_response_ID

Make sure the method is PUT and change the server yul1 to your server. Find the server in the ID at your account setting


I done what you said:

 

  1. Just having 2 elements in the first API
  2. Bringing that elements to second API
  3. And still give an error.

You only need 2 custom path here. 1 is for the survey ID value and 1 is for the response ID value, the rest you can just delete.
$.result.ticketData.elements[2].value

$.result.ticketData.elements[3].value

@Susana_Branco Please read carefully, it’s custom path to the value, you dont need the key, you need to dig deeper into just the value. An iff there’s error please show us the Input JSON it can help with debugging


Thanks!

 

What do you mean by 'it’s a custom path to the value, you don’t need the key'? I think I got lost in translation 🙂 I’m a beginner with APIs."

 

The Json failed output is 

{  "name": "The task is configured incorrectly. Review the task’s configuration then try again.",  "message": "{\"meta\":{\"httpStatus\":\"400 - Bad Request\",\"error\":{\"errorMessage\":\"Invalid surveyId parameter. Empty string values are not allowed.\",\"errorCode\":\"JRP_2.3\"},\"requestId\":\"66000a23-8813-4857-a8e4-4635d0354f56\"}}",  "needRetry": false}

 

The Json failed input is:

{  "payload": {    "actionId": "OCAC_SDKxXOHp1wjXCUE",    "chain": {},    "contentType": "Text",    "createdAt": 1731931156604,    "currentPipedTextTestMappings": {      "": "",      "R_80o7idfCyQ6RXLx": ""    },    "customSaveHandler": true,    "dataTypes": {},    "dependencies": {      "OCAC_Rgpn5jWLy1MqRZN": W        "$.result.ticketData.elementsa3]"      ]    },    "elementConfigured": true,    "encodeQueryParams": true,    "exportMappings": {      "$.meta": "$.meta",      "$.meta.error": "$.meta.error",      "$.meta.error.errorCode": "$.meta.error.errorCode",      "$.meta.error.errorMessage": "$.meta.error.errorMessage",      "$.meta.httpStatus": "$.meta.httpStatus",      "$.meta.requestId": "$.meta.requestId"    },    "exports":        {        "display_name": "Headers",        "key": "headers"      },      {        "display_name": "Status Code",        "key": "statusCode"      },      {        "display_name": "Data",        "key": "data"      },      {        "display_name": "meta",        "key": "$.meta"      },      {        "display_name": "meta.error",        "key": "$.meta.error"      },      {        "display_name": "meta.error.errorCode",        "key": "$.meta.error.errorCode"      },      {        "display_name": "meta.error.errorMessage",        "key": "$.meta.error.errorMessage"      },      {        "display_name": "meta.httpStatus",        "key": "$.meta.httpStatus"      },      {        "display_name": "meta.requestId",        "key": "$.meta.requestId"      }    ],    "headers": {      "Accept": "application/json",      "Content-Type": "application/json",      "x-api-token": "Q21"    },    "icon": "https://www.xm-apps-static.com/assets/v1/APP_42a7f4b6-bb84-4c66-94cc-e3e1208e62bf/1.8.11/KVIQyJoZ1IV3kyIb/images/logo.svg",    "id": "PLUG_7b318b05-433e-4e0c-bef8-520ebe5a0c9a",    "keyValues": {      "text": "{\n  \"surveyId\": \"\",\n  \"resetRecordedDate\": true,\n  \"embeddedData\": {\n   \"Posresolucao\": \"sim\"\n  }\n  }"    },    "metadata": {      "lazyLoadPipedText": true,      "tags":          "wf-schematized",        "survey"      ],      "taskNameInModalTitle": false,      "worker": {        "type": "runner"      }    },    "name": "Non-authenticated web service",    "outcomeId": "OC_R2eU9YjLFpPygvG",    "ownerObject": null,    "pipedTextConfig": {      "$.meta": {        "isSystemGenerated": true,        "label": "meta",        "value": "{\"httpStatus\":\"200 - OK\",\"requestId\":\"39ed39e8-cab7-43dd-857d-153f4007d40a\"}"      },      "$.meta.error": {        "isSystemGenerated": true,        "label": "meta.error",        "value": ""      },      "$.meta.error.errorCode": {        "isSystemGenerated": true,        "label": "meta.error.errorCode",        "value": ""      },      "$.meta.error.errorMessage": {        "isSystemGenerated": true,        "label": "meta.error.errorMessage",        "value": ""      },      "$.meta.httpStatus": {        "isSystemGenerated": true,        "label": "meta.httpStatus",        "value": "200 - OK"      },      "$.meta.requestId": {        "isSystemGenerated": true,        "label": "meta.requestId",        "value": "39ed39e8-cab7-43dd-857d-153f4007d40a"      }    },    "pipedTextImports": {      "body":          ""      ],      "headers":  ],      "url":          "R_80o7idfCyQ6RXLx"      ]    },    "requestType": "PUT",    "summary": "Create a WebService request that doesn't require authentication",    "surveyId": "izosandbox",    "taskNumber": 1,    "taskRegistryId": "APP_42a7f4b6-bb84-4c66-94cc-e3e1208e62bf",    "textPayload": "{\n  \"surveyId\": \"\",\n  \"resetRecordedDate\": true,\n  \"embeddedData\": {\n   \"Posresolucao\": \"sim\"\n  }\n  }",    "triggerAction": "WebService",    "updatedAt": 1732028588122,    "url": "https://yul1.qualtrics.com/API/v3/responses/R_80o7idfCyQ6RXLx"  },  "user": {    "userId": "UR_eR3S3NpMsFXyAkd",    "brandId": "izosandbox"  },  "executionData": {    "workflowId": "TCK_1oiQGin8vXYgwmM-1732028621696-9-OC_R2eU9YjLFpPygvG_REPLAY_1732028845668_REPLAY_1732029527769_REPLAY_1732029565877",    "runId": "",    "actionId": "OCAC_SDKxXOHp1wjXCUE",    "contextId": "izosandbox",    "uniqueId": "TCK_1oiQGin8vXYgwmM",    "outcomeId": "OC_R2eU9YjLFpPygvG",    "taskToken": null,    "attempt": 0,    "orchestrator": "TEMPORAL"  },  "policies": {}}

 


Hi,

You should not publicly post your API token.


Thanks, I edit it.


 

@Susana_Branco In this piped text, you’re taking the whole JSON object i.e:{ "key": "SurveyID", "value": "SV_agUQBVnQcGsoO7I" }

So add custompath and paste these in, to get only the value in the Ticket API

$.result.ticketData.elementse2].value

$.result.ticketData.elementse3].value

Try the above one first, and piped the data in again and run - because somehow your Response Update API body is not taking the surveyID hence the error message.

If the problem still persit, you need to try switch to using key-value pair type

Key Value
surveyId {a}_in_the_value
resetRecordedDate true
embeddedData.Posresolucao sim

Try it and let me know


Thanks, I edit it.

@Susana_Branco After this post you can reset it anyway


I got the custom path and call in the second api with a pairwise, and still don’t recognize surveyID
JSON OUTPUT:{  "name": "The task is configured incorrectly. Review the task’s configuration then try again.",  "message": "{\"meta\":{\"httpStatus\":\"400 - Bad Request\",\"error\":{\"errorMessage\":\"Invalid surveyId parameter. Empty string values are not allowed.\",\"errorCode\":\"JRP_2.3\"},\"requestId\":\"4fed3ceb-c692-44e0-8b44-e364246d1a3a\"}}",  "needRetry": false}

In the end I will change my token.


@Susana_Branco Hold on, did the success previous API getting the SurveyID in the TicketData in it’s return JSON? Because SurveyID kept comming back empty and I’ve only seen the Ticket Data API run in test. Check back the JSON of TicketData API


It works bringing the “$.result.sourceId” from the 1st task

Thanks very much for the support.

 

 


Leave a Reply