I am using version 9.0 of JIRA. I want to upload pictures as user avatars using the rest API, but I have encountered some problems when program in nodejs。
1. according to the URL, the binary data of the picture is obtained from other places,
2. via /reset/api/2/
` http://IP:PORT/rest/api/latest/user/avatar/temporary?username=SomeOneUserName&filename=icon.png ` to upload the picture as temporary
3. create avatar according to temporary
4. set the user's Avatar as this Avatar
the step 3 is failed. and response status code is 500, but i cannot get detail info.
The code is as follows,
// step 1
const res = await axios.get(AvatarImageUrl, {
responseType: 'arraybuffer',
});
let ImageData = res.data;
// step 2
let Resp = await axios
(
{
method: 'post',
data: ImageData,
headers:
{
"Authorization": `Bearer ${token}`,
"Content-Type": "image/png",
"Content-Length": ImageData.length,
"X-Atlassian-Token": "no-check",
},
}
);
let CropData = Resp.data;
// step 3let Resp2 = await axios
(
{
method: 'post',
data: CropData,
headers:
{
'Content-Type': "application/json",
"Authorization": `Bearer ${token}`,
"X-Atlassian-Token": "no-check",
'Cookie': `${CookieId}`,
},
}
);
context.log("resp2", Resp2);