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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

jira api - add attachment with apollo apollo-datasource-rest or other

I'm trying to add an attachment to an issue from node with "apollo-datasource-rest".

 

async addIssueAttachment(file) {
// file = {createReadStream, filename, size, mimetype, ... }

await this.post("rest/api/3/issue/{issue}/attachments", {}, {
headers: {
"Authorization": "Basic {key},"
"Content-Type": "multipart/form-data",
"X-Atlassian-Token": "no-check",
"Accept": "*/*"
},
file
});

return true;
}

currently getting this error:

ApolloError: 415: Unsupported Media Type

 How do I send the file?

 Should I use something other than "apollo-datasource-rest"?

 

1 answer

0 votes

Hi @kyle brown ,

An "Error 415 Unsupported Media Type" is going to be related to the content-type header, and indicates An incorrect "Content-Type" or no "Content-Type" (when a content type is required) has been defined for the call.  I think it might be the portion for the content type is simply unneeded in this call so removing the following section would be the first recomended test:

"Content-Type": "multipart/form-data"

As the docs do not reference this as a necessary input for the POST, and I confirmed this works in the following format as a direct CURL command in a test instance.

A quick reference point to the example query in the docks and an additional quick test to see if its a syntax error vs configuration issue vs apollo try running the curl command directly to post the image from the command line referenced in the Documentation at the following links noting that the Jira cloud API uses the <username:API_TOKEN> formatting vs server which uses the <username:password> format:

curl -D- -u user:<API TOKEN> -X POST -H "X-Atlassian-Token: no-check" -F "file=@path/to/myfile.txt" https://your-domain.atlassian.net/rest/api/3/issue/<issue_Key>/attachments

If you run this command are you still getting the same 415 error?

and are you able to remove this section per the Apollo settings?

Regards,
Earl

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,104 views 8 28
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you