- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2021 06:42 AM
Morning All,
I'm working on an integration and for some reason am having issues with JSON encoding:
I have to JSON encode the description, short description and work notes when sent. I'm getting a catch error of String contains control character. Below is the description that's tripping it up and the payload being sent, any suggestions are appreciated:
Description:
This is a test description Please ignore this WO request
&
"
'
<
>
Payload (some data redacted):
{
"Header": {
"TransactionID": "INC2072276-2021-09-16 09:22:14",
"USERID": "#####",
"SourceSystem": "#####",
"TimeStamp": "2021-09-16T09:22:14"
},
"CreateServiceRequest": {
"CountryCode": "US",
"ServiceRequest": {
"CustomerTicketID": "INC2072276_0",
"Type": "MAIN",
"Priority": "3",
"Summary": ""Test of incident creation 2021-09-16 NEW with Special Characters"",
"Description": ""This is a test description Please ignore this WO request\r\n\r\n&\r\n\"\r\n'\r\n< \r\n>"",
"Caller": {
"FirstName": "Trevor",
"LastName": "Brown",
"PhoneNumber": {
"Country": "001",
"AreaCode": "###",
"PhoneNumber": "####"
}
},
"Site": {
"SiteShortName": "01805"
},
"CI": {
"SerialNumber": "####"
},
"ATMCustomerMetrics": {
"SSDGCustomer": "false"
},
"NCRMCN": "####",
"Remarks": {
"Remark": [{
"Text": ""2021-09-16 09:22:07 - Simon E Hayward (Work notes)\nCreated from a similar incident INC2072274\n\n"",
"Type": "General"
}]
},
"attribute3": "#####"
}
}
}
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2021 07:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2021 07:19 AM
try with JSUtil.escapeText(String) and then serialize
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2021 08:02 AM
Thank you, swapped the encode with this and now it works perfectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2021 08:06 AM
Great!
🙂