Multipart/form-data attachment pusg using Rest API from Snow->Jira

Ashish Avinav
Tera Contributor

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

10 REPLIES 10

Sanjeev Kumar1
Kilo Sage

Hi,

Try it.

@ http://www.john-james-andersen.com/blog/service-now/rest-based-servicenow-jira-integration-poc.html 

prabhatkuchibho
ServiceNow Employee
ServiceNow Employee

Hi,

Multipart/form-data requests are now supported via the REST action step in the IntegrationHub which comes as part of the ServiceNow IntegrationHub Installer plugin available for a fee in the Madrid release.

The procedure to set this up is explained in the below knowledge article.
How to send Outbound REST request with multipart/form-data

Regards,
Prabhat

Aleksas Kucins1
Giga Expert

You can send binary attachments from ServiceNow to Jira and other platforms with multipart without MID server, however it is pretty complicated. This article explains it:

https://servicenowthink.wordpress.com/2020/04/13/how-to-send-binary-data-with-multipart-from-service...

Community Alums
Not applicable

Can you help me with this?

Mathieu Lepoutr
Mega Guru

Hi Ashish

 

please ensure that the attachment sys_id is correct and corresponds to a valid attachment in SNOW and Verify that the 'Jira Integration Attachment' REST message in ServiceNow is properly configured, specifically the 'Post Attach' HTTP method. and the Content-Type header in your request should be set to "multipart/form-data".

 

While you work on resolving this issue, it's worth considering alternative solutions such as Exalate. I have been using it quite a bit and it works flawlessly cause of the decentralized architecture.