I am trying to download the contents of an attachment from a issue with nodejs. But I always get - Unauthorized (401)
But I do with the same user and token several other calls successfully. is I have the same header in the call. see code below:
async function baixarArquivoXls2(id) {
try {
const headers = {
'Authorization': `Basic ${Buffer.from(conection.username + ":" + conection.password
// 'email@example.com:<api_token>'
).toString('base64')}`,
'Accept': 'application/json',
'Content-Type': 'application/json'
};
const response = await axios.get(conection.urlbase+'/secure/attachment/'+id, { headers });
console.error('OK');
} catch (error) {
console.error('Erro:', error);
}
}
I Tryed by this way too. But get a 404 bad request
null for uri: <mylink>/rest/api/2/attachment/content/24200'
async function baixarArquivoXls3(id) {
try {
const headers = {
'Authorization': `Basic ${Buffer.from(conection.username + ":" + conection.password
// 'email@example.com:<api_token>'
).toString('base64')}`,
'Accept': 'application/json',
'Content-Type': 'application/json'
};
const response = await axios.get(conection.urlbase+'/rest/api/2/attachment/content/'+id, { headers });
console.error('OK');
} catch (error) {
console.error('Erro:', error);
}
}
Where are my error? anybody knows?