Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Save attachment not working with nodejs

ranjith kumar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 28, 2018

Hi,

I am trying to save an attachment through REST API to an issue, using node.js

var options = {
hostname: 'testserver.com, port: 443, 
path: '/rest/api/2/issue/SH-488/attachments',
method: 'POST',
rejectUnauthorized: false,
strictSSL: false,
headers: {
'Authorization': 'Basic ' + new Buffer("username" + ':' + "pasword").toString('base64'), 'Accept': 'multipart/form-data',
'X-Atlassian-Token': 'no-check' },
formData: { "file" : attachment }

};

var req = https.request(options, function (res) {
res.setEncoding('utf8');
res.on('data', function (body) {
console.log('Body2: ' + body);

}); });

but I am not getting any response (no response or error) , could someone help

 

 

1 answer

0 votes
Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 28, 2018

Hey Ranjith,

It's been a while since I've worked with node and nothing jumped out at me while I read through your code. I find that sometimes it's easier to start with a "known good" call and modify from there.

There's another post on Community where someone posted their working node.js code to do just this - that's a good starting point and all you'll need to update is the server address / credentials and the file you want to upload.

Cheers,
Daniel

Suggest an answer

Log in or Sign up to answer