How to set Form-data in Rest Message ( attaching a file )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2016 10:39 AM
Hey guys,
I have everything set up and running the only issue is how to set the request of the rest message to ( -F ) form-data
My curl look like this.
curl https:/<endpoint url>/content \
-H "Authorization: Bearer ACCESS_TOKEN" -X POST \
-F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}' \
-F file=@myfile.jpg
this is what causing the problem !!! the body of the request must be set to -F ( form data )
-F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}' \
-F file=@myfile.jpg
setContent() did not work
.
Any help is appreciated!!
regards
Nagendra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2016 09:58 AM
The backslashes in the request body look suspicious.
postFile.setRequestBody('attributes=\'{"name":"tigers.jpeg", "parent":{"id\":"##########"}}');
Have you tried building this out in the REST API explorer?
Getting Started with REST - ServiceNow Wiki
REST API Explorer - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2016 10:51 PM
I Have the same issue .
When I am request the third Party Api through PostMan with "application/x-www-form-urlencoded" as a "Content-Type" in header
and passing data as a key and the value of xml data under "x-www-form-urlencoded" tab, by this I am getting proper response.
But when I was trying to post the request through RESTMessageV2 in ServiceNow for outbound request , didn't get the response.
getting "![CDATA[No XML was posted to sdk listener]]" as a response.
sm = new sn_ws.RESTMessageV2();
sm.setEndpoint('https://###################/listen.asp');
sm.setHttpMethod('post');
sm.setRequestHeader("Content-Type","x-www-form-urlencoded");
sm.setRequestBody("XML BODY");
Snippet from the ServiceNow Log..
Any suggestion on this really appreciated..
Thanks and Regards,
Subrata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2017 03:10 AM
I had the same issue, got to know that sometimes the third party queue has to be cleared , so i told my third party admin to clear it and it worked. I hope this helps .
Regards,
Shivalkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2016 12:19 AM
Even I have same query , did you solve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2017 06:31 AM
me too, anyone know
bueller