Trying to hit YouTrack's API via axios but I am receiving an unauthorized error, while same params via curl work.
curl:
curl -X GET \
'https://<my youtrack url>/api/issues' \
-H 'Authorization: Bearer perm:<my token>' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json'
axios:
const config = {
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer perm:<my token>'
},
responseType: 'json',
};
axios.get('https://<my youtrack url>/api/issues', {}, config)
.then((response) => {
console.log(response.data);
})
.catch(e => {
console.log('Error: ', e.response.data)
});
The curl correctly returns JSON of my available issues, whereas my axios call returns an error
{error: "Unauthorized", error_description: ""}
Thanks
Send the config as the second parameter, as GET requests don't need the body
axios.get('https://<my youtrack url>/api/issues', config)
.then((response) => {
console.log(response.data);
})
.catch(e => {
console.log('Error: ', e.response.data)
});