-1
Good afternoon, I need to download a profile image of Jira via REST. I can, but jira sends me an image referencing that I don’t have permission to see it (example of how the image is downloaded: image)
const express = require('express');
const cors = require('cors')
const request = require('request')
const app = express()
const download = require('download')
app.use(cors())
function callApiUserPhoto(callback){
const options = {
method: 'GET',
url: `url/rest/api/2/user/search?username=user` ,
auth: { username: "user", password: "senha" },
headers: {
'Accept': 'application/json'
}
};
request.get(options, function(error, response, body) {
if(response.statusCode != 200){
return callback('error');
}else{
download(JSON.parse(body)[0].avatarUrls['48x48'], 'dist')
return callback(JSON.parse(body)[0].avatarUrls['48x48'])
}
})
}
app.get('/', (req, res) => {
callApiUserPhoto(function (response) {
if (response == 'error') {
res.send("ops")
} else {
res.send(response)
}
})
})
app.listen(4000, console.log("Sever online!"))