I have a GET request that returns successfully:
async function getData() {
try {
const response = await axios.get(url, {
auth: {
username: {JIRA USER},
password: {JIRA API KEY}
}
});
console.log(response.status)
return response.data;
} catch (error) {
console.error(error);
}
}
getData()
.then((output) => {
console.log(output)
});
Now I would like to PUT with a payload, which I believe should be a fields object, like this:
async function getData() {
try {
const response = await axios.put(url, {'fields':{'customfield_XXXXX':'this is an update'}} , {
auth: {
username: {JIRA USER},
password: {JIRA API KEY}
}
});
console.log(response.status)
return response.data;
} catch (error) {
console.error(error);
}
}
However when I run it, I get a bad request error.
I can't understand if it is that I am PUTing incorrect with Axios, or accessing the Jira API incorrectly. I thought that maybe I need to put the body in a different location but the docs and other examples suggest I have in the right place.