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
05-13-2016 02:20 PM
Hi Nagendra,
Is your main objective to create a file attachment? If so, the endpoint should end with /attachment/upload if you are using the Attachment API from our REST API. My CURL command looked more like this:
curl "https://instance.service-now.com/api/now/attachment/upload" \
--request POST \
--header "Accept:application/json"
--user 'admin':'admin'"\
--header "Content-Type:multipart/form-data"
-F 'table_name=incident' -F 'table_sys_id=12345678' -F 'encryption_context=undefined'-F 'uploadFile=@ location of the file on file system'
This was constructed using the REST API explorer. At the bottom, there is a cURL link.
The attachment API became available in Geneva. Your screen shot is UI15 so it's hard to tell if that's Fuji or Geneva.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2016 02:25 PM
hey ,
this curl is defined by external 3rd party api.
curl https:/<endpoint url>/content \
-H "Authorization: Bearer ACCESS_TOKEN" -X POST \
-F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}' \
-F file=@myfile.jpg
i want to setup outbound rest message .
how do i set request body to -F( form data )
regards
Nagendra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2016 02:54 PM
H Nagendra,
Just so I'm clear, you want to set up the outbound rest message in ServiceNow to send information to your 3rd party app, or the other way around (3rd party app posting information to ServiceNow?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2016 02:57 PM
i want to set up the outbound rest message in ServiceNow to send information to your 3rd party app.