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

HowTo: Update Asset Custom Fields via REST API

Salzi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 24, 2023

Since this has cost me a lot of nerves over the last few days and unfortunately the documentation is silent about the required values, here is a short HowTo

To update an issue and fields of an issue, use the following REST API endpoint:

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put 

Unfortunately, the documentation says nothing about the format in which elements in an Asset Custom Field should be passed.

This is what the JSON body must look like to fill an asset field. Alternatively, you can of course also use the other keywords from the documentation (“add”, “remove”, etc.):

"update": {
"customfield_XXXXX": [
{
"set": [
{
"workspaceId": "workspaceId ot the Object",
"id": "GlobalId ot the Object (workspaceId:objectId)",
"objectId": "Id of the Object"
}
]
}
]
}

The Global ID consists of the WorkspaceId and the objectId.

 Here is an example of what such a body (with values) could look like:

 

"update": {
"customfield_10217": [
{
"set": [
{
"workspaceId": "ecaa45c7-4578-420f-a2e0-cf7b0da4b5ad",
"id": "ecaa45c7-4578-420f-a2e0-cf7b0da4b5ad:1672",
"objectId": "1672"
}
]
}
]
}

 

I'm happy if the information helps a few more people 🙂

5 comments

Anmol Agrawal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 1, 2023

@Salzi This is great!!!! Thanks a lot. I will test this out and if everything is fine, we will add it our documentation and sample apps. We really appreciate this.

Like Salzi likes this
Nijas Bijily Rawther
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 14, 2024

@Salzi Are you sure "add"/"remove" operations will work ? I see only "set" in the operations list for the asset custom fields. 

This is for a scenario, when we want to just add a new Asset to an Asset custom field which supports multiple objects. 

Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 24, 2024

@Salzi Thanks for the explenation.

This saved me a lot of time to figure it out myself!

Like Koen Gillard likes this
Alex Ziegltrum March 7, 2024

@Salzi Thanks for sharing your findings, but I can't get it to run via postman.

Using this endpoint: 

https://mycompany.atlassian.net/rest/api/3/issue/{{issue}}

With:

"update": {

    "customfield_10190": [

       {

         "set": [

              {

                 "workspaceId": "my-workspace-id",

                 "id": "my-workspace-id:30409",

                 "objectId": "30409"

              }

           ]

        }

    ]

}

I get:

{

    "errorMessages": [

        "Invalid request payload. Refer to the REST API documentation and try again."

    ]

}


Could you please check, if you have a different body in the postman request?

Thanks and Cheers, 

Alex

Christoph Kaminski
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 21, 2024

does the on-premise JIRA/Assets solution has a workplace id to?

How can I set such a custom field in the on-premise JIRA?

TiA

Greetings

WW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2024

I was able to find the on-premise examples here. It's much simpler.

You just do a regular PUT Jira REST API issue edit of the custom field.

What you pass as the value is different from most custom fields, but simple enough.

Available actions are: add, set, remove.

For example:

{"update":{"customfield_98765":[{"add":[{"key":"TEST-123456"}]}]}}

The key value is the asset key.

Like Jira DC testing likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events