You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I want to upload an image as an Avatar to an Insight object from my code, ideally using a Rest call.
https://documentation.riada.io/display/ICV50/Insight+with+JIRA+REST-API
lists only a get method to retrieve the Avatar but not to set it.
Now, when I upload it manually I can sniff on the network a call to:
<jira-base-url>/jira/plugins/servlet/com.riadalabs.jira.plugins.insight/avatarupload
I also add the file and as usual the
headers = {'X-Atlassian-Token': 'no-check'}
I end up with the error message:
{
"error": {
"system": "Upload error, are you uploading a valid image?"
}
}
in the response header. I get the same when using eg. Postman to call the endpoint. When I replay the call from the network sniffer it does work with the same file.
Does somebody have a similar issue, and were you able to overcome it? Any hints welcome.
Many thanks in advance.
Christian.
{
"attributes": [
{
"objectTypeAttributeId": <objectTypeAttributeIdOfLabelAttribute>,
"objectAttributeValues": [{"value": "Test Avatar"}]
}
],
"objectTypeId": <objectTypeId>,
"avatarUUID": "<yourUUID>",
"hasAvatar": true
}
Hi Alexander,
this works for me, thanks a lot.
Here is what I sent along with for the first POST request:
import uuid
...
url = "{}".format(
Config.urls()["base_url"]
+ "jira/plugins/servlet/com.riadalabs.jira.plugins.insight/avatarupload"
)
uid = str(uuid.uuid4())
logging.info("Generated UUID %s: ", uid)
data = {"avatarUUID": uid,
"name": "rlabs-insight-object-avatar"}
r_post = send_request(url, None, "post", data=data, filename=filename)
it does not have to be uuid4, any of the options will do.
Best regards,
Christian.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To upload avatars i use this endpoint now: /rest/insight/1.0/avatar/upload
Example:
#!/bin/bash
# generate uid
uid=$(uuidgen | tr "[:upper:]" "[:lower:]")
# upload picture
curl -v -H "X-Atlassian-Token: 'no-check'" -H "Authorization: Bearer <TOKEN>" -F file=@picture.jpg -F avatarUUID=$uid <BASE_URL>/rest/insight/1.0/avatar/upload
# set picture as avatar on object
curl -v -H "Content-Type: application/json" -H "X-Atlassian-Token: 'no-check'" -H "Authorization: Bearer <TOKEN>" -X PUT --data '{"attributes": [{"objectTypeAttributeId": <objectTypeAttributeIDtoUpdate>,"objectAttributeValues": [{"value": "<VALUE>"}]}],"objectTypeId": 1,"avatarUUID": "'$uid'","hasAvatar": true}' <BASE_URL>/rest/insight/1.0/object/<OBJECT_ID>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.