Uploading attachments via REST API using axios Edited

I'm having a lot of trouble uploading an attachment to a created issue using the REST API. Currently I'm getting a 415 - "unsupported media type" error. 

I would really appriciate some help with this. Thanks! 

 

let actionData=new FormData();
actionData.append('file', files[0]);
actionData.append('comment', "foobar");
actionData.append('minorEdit', "true");
axios({
      method: 'POST',
      url: jiraApiUrl+'/issue/'+issueID+'/attachments',
      headers: {
             'X-Atlassian-Token': 'nocheck',
      },
data: actionData,
}).then(response => {
              //if (!cb) return { error: 'No callback' };
             console.log('response-2', response);
             return ;//cb(response);
})
.catch((err) => console.log('errorTest - files', err));

1 answer

0 votes

I'm not sure about using axios, but from looking at other instances with this error such as

How to change the mediatype of an attachment via REST API

REST API error 415 unsupported media type

It seems like this might be a problem with a lack of a content type paramenter.   I think you might need to clarify the request by adding a

'Content-Type: application/json'

somehow to this REST.   But I also think you will need to modify the

'X-Atlassian-Token': 'nocheck'

to be

'X-Atlassian-Token: nocheck'

 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,897 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot