Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,647
Community Members
 
Community Events
185
Community Groups

Why attachments are not being added in JIRA when sent from Servicenow

During JIRA ServiceNow integration , when attachment is sent from servicenow but not added in JIRA Issue attachments . why it is not added in attachment and what is left to be done so that it can get added

1 answer

1 accepted

0 votes
Answer accepted
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 04, 2022

Hi @Prajwal Ashok Nagrale and welcome to the community,

How did you integrate SN and Jira? Are you using a Plugin? If so: which one? How are attachments sent to jira?

Please share some more details regarding your problems. This helps the community to find a solution.

Best
Stefan

Hi, we have used REST Api to *integrate SN and JIRA . 

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 07, 2022

In order to be able to analyse the problem the community please add some deeper insight and details.

Without knowing how your integration/calls look like, where are they triggered, how is api call sent, etc... the community could just do guesses.

Best
Stefan

Integration call through business rule of serviceNow

(function executeRule(current, previous /null when async/ ) {    

var arr = [];    

var gsu = (typeof GlideStringUtil != 'undefined') ? (GlideStringUtil) : (Packages.com.glide.util.StringUtil); //few versions support the first one, other supports second    

var gsa = (typeof GlideSysAttachment != 'undefined') ? (new GlideSysAttachment()) : (new Packages.com.glide.ui.SysAttachment());  

 var gr = new GlideRecord("sys_attachment");

gr.addQuery('table_sys_id', current.table_sys_id);

gr.query();    

 

while (gr.next()) {        

var attachmentData = gsa.getBytes(gr);        

var attachment = String(Packages.java.lang.String(attachmentData));        

var encData = GlideStringUtil.base64Encode(attachmentData);        

var obj = {};        

obj["content_type"] = gr.getValue('content_type');        

obj["file_name"] = JSUtil.escapeText(gr.getValue('file_name'));        

obj["size_bytes"] = gr.getValue("size_bytes ");        

obj["sys_id"] = gr.getUniqueValue();        

obj["Content-Transfer-Encoding"] = "base64" +  encData.toString();        

arr.push(obj);    

}    

 

var finalObj = {};    

finalObj["attachment"] = arr;    

var sm = new sn_ws.RESTMessageV2('Neste Siili JIRA', 'Add attachment');    

var response = sm.execute();    

var status = response.getStatusCode();    

gs.info("Payload sent jira: " + sm.getRequestBody());    

gs.info("Response jira: " + response.getBody());    

gs.info("Status jira : " + status);

})(current, previous);

 

 

Payload  --

{
      "attachments": [{
          "content_type": "image/png",
          "file_name": "Screenshot (153).png",
                "size_bytes ": "137246 ",
          "sys_id": "f576b5211b091950f7b82fcde54bcbae",
"Content-Transfer-Encoding": "base64${base64EncodedData}"
      }]
  }

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 07, 2022

Hi @Prajwal Ashok Nagrale 

I do not know any engine of SN. I can just reflect the issue from Jira perspective. 

So which endpoint of the jira API are you calling? How do you determine the issue key where the attachment should be added?

Best
Stefan

Hi,

Just want to know in Which format Jira accepts an Attachment using Rest API ?

 

Regards,

Prajwal

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 08, 2022

Hi @Prajwal Ashok Nagrale 

This is an example how an attachment can be added via curl api call:

curl --location --request POST 'https://your-domain.atlassian.net/rest/api/3/issue/TEST-123/attachments' -u 'email@example.com:<api_token>' -H 'X-Atlassian-Token: no-check' --form 'file=@"myfile.txt"'

 

see detailed documentation here:

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post

 

Hope this is helpful.

Best
Stefan

Hi,

 

Can you check whether this payload is correct for jira.

{
"attachment": [{
"content_type": "text/plain",
"file_name": "test.txt",
"size_bytes": "2",
"sys_id": "1326b90a1bc3d51014811023b24bcb5c",
"Content-Transfer-Encoding": "base64dHQ="
}]
}

 

and the reponse from JIRA is Blank. do you know why the response is blank ?

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 10, 2022

To be honest I´m not a developer. I can handle easy api calls as described in the documentation. So adding attachment via curl (as described above) worked in my system.

What I could find in the community was the following post. The question from Radek on 11.02. might cover your problem:

https://community.atlassian.com/t5/Jira-Core-Server-questions/Upload-attachments-on-Jira-through-the-REST-API/qaq-p/1941991

 

Best
Stefan

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events