How do I send a Jira attachment using Webhook

I am developing an integration to sync ServiceNow incidents <-> Jira issues.
All fields have been defined and are moving in both directions with no issues.
I am having an issue with Jira attachments being sent to ServiceNow.
ServiceNow has an attachment api to support inbound attachments, however, I do not know how to setup the webhook to call that API.

Any assistance would be greatly appreciated.

I think that an attachment will cause the jira:issue_updated to be triggered. You’d have to identify the attachment that was uploaded and then essentially download it using the rest api by using https://docs.atlassian.com/jira/REST/cloud/#api/2/attachment-getAttachment to get the locations and the other metadata.

Then you’d do a post (I think - I’m not a ServiceNow developer) at https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/integrate/inbound-rest/reference/r_AttachmentAPI-POST.html using the metadata that you extracted from the getAttachment. In theory you could probably do a pipe in between the fetching and such.

Again - not a ServiceNow developer so I can’t speak to that side.

3 Likes

Unfortunately, calling the getAttachment only gets me the information about the attachment. ServiceNow is a cloud application and does not have access to the location of the actual attachment. I was hoping that Jira/Webhooks would be able to execute the post to ServiceNow. Or, that Jira would have a REST api call that would allow ServiceNow to retrieve the binary/byte array/base64encodedstring , etc of the file in the JSON payload. Receiving this would allow ServiceNow to attach that payload as an attachment in ServiceNow.

Well the getAttachement returns the url of the content location. So ServiceNow would need to request it and extract it from there.

If you’re still looking into this, Perspectium offers integration as a service that ebonds ServiceNow and JIRA, supporting bi-directional sharing of case details, work notes, and attachments. Check out www.perspectium.com/atlassian if you’re interested.

Hi @kevin.mauriello…did you get this attachment situation from Jira to SNOW figure out? I am having the same issue and I havent found a solution. And I dont have the luxury to get a paid-plugin.

Any input/assistance is greatly appreciated.

Thank you

I did. Although the REST API only returns the url of the attachment you can still “pull” that attachment into ServiceNow. You need to make a REST GET call from ServiceNow using the url and basic authentication. If you have to use a mid server on the ServiceNow side it gets a little tricky. But that can also be done.

saveJiraAttachmentInSN: function(targetInstanceURL, sTable, sSysID, sFile) {
	var targetUserID = this.jira.user;
	var targetUserPassword = this.jira.pwd;
	try {
		var attachmentMessage = new sn_ws.RESTMessageV2();
		attachmentMessage.setHttpMethod("get");
		attachmentMessage.setBasicAuth(targetUserID, targetUserPassword);
		attachmentMessage.setEndpoint(targetInstanceURL);
		attachmentMessage.saveResponseBodyAsAttachment(sTable, sSysID, sFile);
		var response = attachmentMessage.execute();
		var sStatus = response.getStatusCode();
		if (sStatus != '200')
			this.jira.debug(response.getErrorMessage());
		else
			this.jira.debug('attachment saved: ' + sFile);
	} catch(ex) {
		this.jira.debug('ERROR in saveJiraAttachmentInSN ' + ex, true);
	} finally {
		this.jira.sendToLog();
	}
},

Thank you Kevin!..really appreciate it!

I will give it a try and keep you posted.

Thank you very much

No problem, I have become some what of a ServiceNow integration/Jira/attachment expert over the years. I am a consultant, so if your company is looking for a ServiceNow developer, keep me in mind.

awesome…where are you located? I actually recently started a LLC with two of my ex-colleagues from AT&T and we are super busy with projects…so we might be able to work together…send me an email to tomas.arguinzones@tajconcultinggroup and we can go from there.

Thanks Kevin!

i tried
tomas.arguinzones@tajconcultinggroup
tomas.arguinzones@tajconcultinggroup.com
both kicked back as undeliverable.
here is mine, kevinmauriello@gmail.com

Thankyou Kevin! This is helpful! Were you also able to send attachments from ServiceNow to JIRA? How did you achieve that?

Thanks in advance!