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 03:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2016 01:34 PM
Hi rbeeman that did not work
i want to set body to form data
-F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}' \
-F file=@myfile.jpg
any idea ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 04:00 PM
Hey ctomasi
I am trying to make an outbound rest message call which includes a file attachment.
any idea how this can be done ?
any feedback on this is really appreciated
regards
NB

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2016 04:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2016 09:56 AM
yes I have looked into ,
so here is what I am doing
var postFile =new sn_ws.RESTMessageV2();
postFile.setEndpoint('https://###################/content');
postFile.setHttpMethod('post');
postFile.setRequestHeader('Content-Type','multipart/form-data');
postFile.setRequestBody('attributes=\'{"name":"tigers.jpeg", "parent":{"id\":"##########"}}');
postFile.saveResponseBodyAsAttachment('0c1b9818db212200fd283740cf96196f');
var res=postFile.execute();
i get back 500 response
same call using postman
i get response 200
the issue is I have to set the content of the body to form and give them a key value pair.
have gone through every post in the community , I did not see any post which says how to set Form-data
any help on this is really appreciated
Regards
NB