- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2023 03:33 AM
We have setup one REST message integration from our serviocenow to 3rd party ServiceNow instacne between SC task.
So whenever we attach any attchment to our task it should sent that attachment to 3rd party task, but getting error as mentioned in below screenshot. please suggest. as its not passing the attachment.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2023 07:52 AM
Instead of using setStringParameterNoEscape() function try to create a json format. setStringParameterNoEscape() function is mostly used for formdata format of rest api request body whereas as per you requirement you need to have a raw data format in json. for that you need to try using below code to create a JSON
var r = new sn_ws.RESTMessageV2('SOCIntegrationTask', 'Update Task');
var body = '{ "application" : "' + current.u_application + '", "taskid" : "' + current.u_task_id + '", "status" : "' + stateChange + '", "targetassignmentgroup" : "' + assignmentGroup + '"}';
r.setRequestBody(body);
var response = r.execute();
You are getting HTTP 500 which means internal server error. This usually happens when server is not able to understand what needs to be execute or what unable to understand request body parameter. Therefore try the above format for request body.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2023 03:45 AM
it clearly says that the json request body is not a valid one.
Did you check by adding logs how the request body looks like?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2023 06:06 AM - edited ‎06-27-2023 06:07 AM
I Just put the logs and found it is having such value "SCTASK0022969 RequestBody [object RESTResponseV2]"
As per the design document it should be as mentioned below.
Request Body –
{"file_name":"Test",
"content_type":".png",
"ticket_number":"TASK034572",
"fileData": "my sample file"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2023 06:14 AM
check these links
Unable to send attachment via REST
Business rule to send attachment to 3rd Party Tool via REST
Send attachment via rest message
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2023 02:54 AM
I have seen all the links provided by you, my scripts seems to be correct but not sure why for attachment passing only its not generating the correct request format