Webservice task JSON freetext no longer working | XM Community
Skip to main content

Hi All,
Over the last year I've been setting up workflows using various tasks such as create and update ticket tasks aswell as webservice tasks that feedback any changes from said tickets back to the embedded data fields of the survey connected to the tickets. I started off with using key-value pairs and then managed to migrate to JSON freetext which meant it was a lot quicker to setup as I could use excel to create the JSON string.

I recall Qualtrics support helped me understand and develop the free text format which has worked fine for some time. However as of now (Sept 2022) whenever I edit one of the JSON free text strings, it stops working and reports a specific error (see below), which I think is due to it not being parsed correctly now - it might be adding or leaving in a backslash where it shouldn't be. I have tried numerous techniques such as moving away from double quotes but still have the same problem. Below are a few screen shots.
This webservice works in it's current form which uses key-value pairs:

Request: PUT
Url: https://eu.qualtrics.com/API/v3/responses/${tck://Field/responseId}

image.pngthe embeddedData field string from above is :
{"GE_T_Apology_Sent":"Y","GE_T_Apology_Sent_Date":"${tck://Field/updatedAt}"}
this works fine.

If you try and use this in the form of free text you convert it to the below where you have to escape the double quotes within the embeddedData field part.
{"surveyId":"SV_********","resetRecordedDate":"false","embeddedData":"{\\"GE_T_Apology_Sent\\":\\"Y\\", \\"GE_T_Apology_Sent_Date\\":\\"${tck://Field/updatedAt}\\"}"}


This code used to work, but upon editing it, it no longer works and throws the following error:
{
"name": "The task is configured incorrectly. Review the task’s configuration then try again.",
"message": "{\\"meta\\":{\\"httpStatus\\":\\"400 - Bad Request\\",\\"error\\":{\\"errorMessage\\":\\"Expected param not found: surveyId\\",\\"errorCode\\":\\"RP_10\\"},\\"requestId\\":\\"99f60971-93cb-4657-b874-6a64eafd43f8\\"}}",
"needRetry": false
}

Qualtrics support have mentioned (so far) that it might be that the embedded fields are ending up having a backslash being appended onto them. eg. 'GE_T_Apology_Sent_Date' becomes 'GE_T_Apology_Sent_Date\\' and suggested I remove all the backslashes but this hasn't helped nor made a change to the error message.

Has anyone experienced this and found a workaround? It sounds like the parsing engine has changed behind the scenes and no longer likes a double quote being escaped by a backslash (hence this is why I tried single quotes but still couldn't get it to work).

Thanks

Rod Pestell

Hi Rod_Pestell,
I haven't encountered this issue myself, but have encountered similar issues when piping in values via Javascript. Sadly my solution won't work for JSON.
"It sounds like the parsing engine has changed behind the scenes and no longer likes a double quote being escaped by a backslash"
This gave me an iea - have you tried inserting without the escape characers? eg:
{"surveyId":"SV_********","resetRecordedDate":"false","embeddedData":"{"GE_T_Apology_Sent":" "Y", GE_T_Apology_Sent_Date:"${"tck://Field/updatedAt"}}}"
Seems ridiculous I know, but if the piped value now includes the double quotes it may work.
Good luck!


Hi bgooldfed ,
Thanks for the reply. Yes - I tried removing all back slashes but it still gave the same error. I checked out your edit too and tried it directly but it wasn't accepting it. Can you confirm that the JSON Freetext works for you in your account? Could you possibly paste an example as perhaps this is simply down to a missed quote or space or curly bracket.
Thanks
Rod Pestell


Hi Rod_Pestell,
I've just tried it on a dummy workflow and my suggestion did not work. Your initial text with the backslashes did work however. I literally copy pasted it and only changed the Survey ID / response ID.
image.pngNo idea why yours is not working in this case :S


HI bgooldfed ,
Thanks for doing some tests. that's interesting to see that it works for you but it looks like you tried this using the 'run test' method. This too works for me but it's when you actually run it though a trigger (eg. change the status of a ticket or create a survey response). That's when it fails for me. Can you confirm that it also works in the normal way for you? If so I will be very interested to know that and it might re-direct my investigations.
Thanks
Rod Pestell


Hi Rod_Pestell,
I've just tried it after a normal trigger and I think I've found part of your issue.
Recreating your issue as described gave the error. The only things I changed were the survey ID, response ID and the embedded data fields so they matched ones that existed in my test survey.
Trying it with just one embedded data field however got a 200 OK response. It did not actually update the response for some reason, but maybe I have done something wrong.
eg:
// this errors
{"surveyId":"SV_********","resetRecordedDate":"false","embeddedData":"{\\"GE_T_Apology_Sent\\":\\"Y\\", \\"GE_T_Apology_Sent_Date\\":\\"${tck://Field/updatedAt}\\"}"}

// this gets an OK response
{"surveyId":"SV_********","resetRecordedDate":"false","embeddedData":"{\\"GE_T_Apology_Sent\\":\\"Y\\"}"}
Not sure why this happens or how you can solve it, but hopefully it's a piece of the puzzle.


Hi bgooldfed
I'm still having problems. Just to check, did you get that OK response by using a trigger within the workflow (eg ticket changed status) - so in the 'run history' tab you got a 'succeeded' message? ...OR did you use the 'run test' method from within the webservice?

Can you send me a screen shot of your webservice setup (obviously remove your API token)?
Thanks
Rod Pestell
image.png


https://community.qualtrics.com/XMcommunity/discussion/comment/49523#Comment_49523From a survey completion trigger. Screenshot below in case anybody else finds their way to this thread. (I am using an embedded field labelled "Result" because that already existed in my survey project).
image.png


Have you tried setting the Body to "Plain Text"?
Be warned, you will need to change the Content-Type back to application/json as that automatically changes when you select "Plain Text"


Screen Shot 2022-09-15 at 1.43.20 PM.png


https://community.qualtrics.com/XMcommunity/discussion/comment/49579#Comment_49579Radam Thanks so much for that pointer - that seems to have got it!! 😃 It's now working. I needed to remove he double quotes from the false as that is a boolean but other that that it worked!! :)

Thanks for much Radam and bgooldfed I've been taring my hair out on this one.
I'll come back shortly having done some extra tests and checking to see whether my original coding now works.
Thanks
Rod Pestell


Radam i am facing a similar issue however my setup under Body is JSON - Free text. I have escalated it to Qualtrics engineers however no luck so far and we have our services failing whenever it cannot parse. Any help or support is much appreciated.
parse issue.pngI have TID-1 Webservice to create a CX Response from 360.
I have a TID-2 Webservice to update 360 Response with CX Response ID
image.png


HI aalokjain ,

The body needs to be set to free text and then you need to go back and change the Content-Type field back from plain text to application/json as it changes to plain text when you change the body field.

Then just make sure the JSON string is good and all the doubles quote etc. are paired up.

Hope that helps

image.png


☝️what Rod said 😀


Ok what we have discovered is, the carriage return is causing an issue, however other special character issues are resolved.
Original response as below :
-bullet one
second sentence
-second bullet
JSON output which Failed Response for the above entry in comments section :
\\n\\n-bullet one
So anything with \\n\\n is failing as its a carriage return which is not parsing.

Unsure how to overcome that.


Still failing for carriage returns :(


Hi All,
I just wanted to update this thread as I'm still having problems (once editing an old task). I think I've discovered what the error message 'Expected param not found' was going on about. I discovered that in the input JSON log of each webservice call, it was injecting a dataTypes field. I discovered this by comparing a webservice that was working last week but as soon as I'd made a change, then this field started to appear in the log. When you use the key-value pairs mode, you are asked to enter the label and variable like you do in the free text mode but also it asks you for the data types. So I think what has happened is that Qualtrics (sometime last year) made a a change and for the free text mode in that you also need to inject the dataType into the free text part of the JSON string.

There doesn't seem to be any info from Qualtrics about how you do this. I've raised a ticket but not expecting much so reaching out here aswell. My question is how do you inject the dataTypes parameter into the free text version of the JSON string?

image.png I'm able to get this dataType part populated via using the key-value pairs but am not sure how it gets populated by the normal free text approach
image.png

This is the webservice that I mnaged to get back working using the Key-value paris (I'd prefer to use the free text mode though)
image.png
and this is how the input JSON log is now
image.png
Thanks

Rod Pestell


Whenever placing piped text in JS variables I would recommend using back ticks.
Otherwise if you have line breaks in the piped text it will break your JS code.

// when using double quotes JS does not allow multi line text to be placed between them
// this can cause errors if you hand over a value with line breaks
const myErrorProneValue = "${e://Field/myField}";

// when using single quotes JS does not allow multi line text to be placed between them
// this can cause errors if you hand over a value with line breaks
const myErrorProneValue = '${e://Field/myField}';

// when using back ticks JS allows multi line text to be placed between them
// this will not cause errors for values containing line breaks
const myWorkingValue = `${e://Field/myField}`;

 


Whenever placing piped text in JS variables I would recommend using back ticks.
Otherwise if you have line breaks in the piped text it will break your JS code.

// when using double quotes JS does not allow multi line text to be placed between them
// this can cause errors if you hand over a value with line breaks
const myErrorProneValue = "${e://Field/myField}";

// when using single quotes JS does not allow multi line text to be placed between them
// this can cause errors if you hand over a value with line breaks
const myErrorProneValue = '${e://Field/myField}';

// when using back ticks JS allows multi line text to be placed between them
// this will not cause errors for values containing line breaks
const myWorkingValue = `${e://Field/myField}`;

 

Also, if there are multiline text to be piped in the webservice then free-text format then we can also use code task to first JSON.stringify the text and then pipe this result without quotes in the Web service JSON body.


Leave a Reply