Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Insight Rest API: Object Avatar Upload Edited

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.

1 answer

1 accepted

0 votes
Answer accepted
  1. You have to define a UUID for the avatar and send that along the request. So you send multipart/form-data with parameters:
    1. file - your file
    2. avatarUUID - your UUID
  2. Next, you need to update the Insight object via PUT /rest/insight/1.0/object/<objectId>, json body is like this (you have to send at least one attribute value or it will return 400):
{
"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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

225 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you