imperative
imperative copied to clipboard
Using RestClient.getExpectJSON and getting what appears to be mangled values returned - also with getExpectString
I am using RestClient.getExpectJson and getting this back:
**Command Error:
The get request appeared to succeed, but the response was not in the expected format:
Unexpected end of JSON input**
No data is returned and it is very difficult to debug why.
I changed the code to now issue a RestClient.getExpectString so that I can see exactly what is coming back without it being interrupted by a JSON parse getting in the way.
What I am seeing is that I have a vertical broken bar character in a field .
"lastPromotionSite":"¦ STEV",
We have changed our Server code to recognize that the vertical broken bar is actually a double byte character and hence why we were short by 1 character - the missing } at the end of the string.
However, as a result of me changing to getExpectString, it has thrown up an odd situation.
Here is the partial “string’ that I am getting back looks like this: Notice the isMa...jected .. That is actually 4 fields that are not present and the 'jected": N" is the end of the 5th field. I have found that if I then run JSON.parse on the returned string - the observed corrupted string is in fact not corrupt and is presented perfectly fine. So had I not returned it as a getExpectString, thsi would never have surfaced as an issue.
isFreezePending: "N",
isInstallPending: "Y",
**"isMa…jected": "N",**
isRevertPending: "N",
isShortApproverListUsed: "N",
When we run this same REST api through POSTMAN it is working fine with no 'corruption' observed.