
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Write SM Script to upload file to third party system using doHttpRequest method
Hi, can any expert here share with me how I can write the script in SM using doHttpRequest to upload file to third party system via their Rest API as shown in the attached jpg which I can do successfully using Postman?
The file to upload is specified in the post request body using form-data. I'm not sure how to specify that in SM script.
Thanks in advance.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi,
Here is what i did:
1) Add and attachemt to incident
2) Create a button on incident to POST attachment using script, something like this:
var attachmentArray = new Array();
var attachmentObj=system.vars.$L_file.getAttachments();
for(var attachment in attachmentObj) {
if(attachmentObj[attachment].len>xxxxxxx) { /*check the attachmet size, if its oversized then quit
return "file too big"
} else {
attachmentArray.push({"name":attachmentObj[attachment].name,"data":base64Encode(attachmentObj[attachment].value)});
}
...
var objCreate = {
"attachments":attachmentArray
}
/* POST */
Regards,
Ainer