Right now I am able to upload an attachment via Postman but when I try to do it in my Node.js project I get either a 404, 415 or 500 error. I have tried multiple times changing "Content-Type" to different types and adding and taking away headers but nothing seems to work.
Here is the code I have currently and this returns a 500 error:
I have also tried clicking Code in postman and copying and pasting that exact code into my project. With that I get a successful 200 status code but the attachment isn't showing up in the issue.
And here are screenshots of the code to get a better look:
This code is what got it working for me. You have to actually make a curl request in your Node project in order to upload an attachment to a Jira ticket. Pretty ridiculous but I couldn't find anything that worked better. To my knowledge it isn't possible with axios.
let formData = new FormData(); let stream = fs.createReadStream(fileTempName, 'utf8'); formData.append('file', stream); let formHeaders = formData.getHeaders();
let res = await axios.post(urlString, formData, { headers: { 'Accept': 'application/json', 'Authorization': Basic, 'X-Atlassian-Token': 'nocheck', ...formHeaders } });
let formData = new FormData(); let stream = fs.createReadStream(fileTempName, 'utf8'); formData.append('file', stream); let formHeaders = formData.getHeaders();
let res = await axios.post(urlString, formData, { headers: { 'Accept': 'application/json', 'Authorization': Basic, 'X-Atlassian-Token': 'nocheck', ...formHeaders } });