Announcing the Global SNUG Board of Directors. Learn more here
07-23-2018 05:53 AM
Hi All,
We are integrating ServiceNow with JIRA .We are facing issue with attachment push from SNOW->JIRA.
As we have to use Content-Type as "multipart-form-data", am not able to set request with attachment that need to be send.
Seems like setRequestBodyFromAttachment('sys_id') is not working, as its returning Http Status -200, but no response object.
Below script am using:
try
{
var req = new sn_ws.RESTMessageV2('Jira Integration Attachment', 'Post Attach');
req.setStringParameterNoEscape('key', event.parm1);
req.setRequestHeader("X-Atlassian-Token","no-check");
req.setRequestHeader("Content-type","multipart/form-data;boundary="+file[i].id); // file[i].id- sys id of attachment
req.setRequestHeader("Accept","application/json");
req.setMIDServer('mid-sever name);
req.setEccParameter('skip_sensor', true);
req.setStringParameter("file",file[i].name); // name of file
req.setRequestBodyFromAttachment(file[i].id); // sys id of attachment
var res= req.execute();
var resBody= res.getBody();
}
catch(ex)
{
gs.log("exception : "+ex);
}
Please help with this.
Thanks,
Ashish Avinav
07-23-2018 02:25 PM
Hello,
Don't think that the multipart/form-data header is supported.
Have read on the Community that this should work when using an MID server, but nothing that I’ve had the possibility to investigate further.
When we faced this issue, we solved this by using a third party in the middle. (NodeJS app)
10-09-2018 12:50 PM
I was facing the same issue, got HI team on this and servicenow DOES accepts form-data format, although it wont accept files to be attached (unless you are on LONDON and the IntegrationHub plugin has been purchased ($$$$), and it will be available ONLY on "Flow Designer").
Try this:
var r = new sn_ws.RESTMessageV2('<12312312312321>', 'POST');
var var1 = "test1";
var var2 = "test2";
var var3 = "test3";
r.setStringParameterNoEscape('form1', var1);
r.setStringParameterNoEscape('form2', var2);
r.setStringParameterNoEscape('form3', var3);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
Please mark as this as helpful if it was.
Regards
01-02-2019 05:41 AM
I have tried to debug code from another thread and works perfectly for me. I have posted complete solution code here - https://community.servicenow.com/community?id=community_question&sys_id=0679b3b0dbfeeb00f21f5583ca96...
06-19-2023 11:59 AM
Hello Ashik. your link is not working. Could you please share it again?