Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to update a custom field MultiPicker via Rest API V3

Rajesh Ale February 10, 2022
Trying to update custom field via Rest API V3 with below json

'{
"fields": {"customfield_12904": [{"name": "admin"}]} }'

HTTP PUT https://<xx>/rest/api/3/issue/${issueKey}

It gives me 204 No Content. But on the UI I dont see its getting updated. 

2 answers

1 accepted

3 votes
Answer accepted
Prince Nyeche
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.
February 10, 2022

On cloud you should always use accountId when it comes to a user field. In this case for a multipicker field that should be:

'{"fields": {"customfield_12904": [{"accountId": "5abcXXX"}]} }'
Rajesh Ale February 10, 2022

Yes, by sending accountId it worked. but generally I get emailAddress , is there a way for JIRA to pick accountId automatically ??

Prince Nyeche
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.
February 10, 2022

You will need to create some sort of datastore that relates an accountId to an emailAddress and call that from a function. On cloud, emailAddress is an object that is restricted based on the users' preference, so you do not want to rely on that object.

In terms of multi-picker fields, if you want to append users

  • Your code should get the current value on an issue.
  • Create a function that determines the accountId if you're getting emailAddress from your request.
  • Use the accountId lookup and generate your payload that will be updated. In this instance, you should append your payload to the customfield_12904 list.
0 votes
Pramodh M
Community Champion
February 10, 2022

Hi @Rajesh Ale 

Welcome to the community 🙂

Better Get the Issue from API, you'll have the format to edit the custom field via API that you need to be reflected in Jira

First make a GET call to Issue. Take a look at the format and use the same white editing (POST) the issue 

Let me know if that works

Thanks,

Pramodh

Rajesh Ale February 10, 2022

Thanks for the welcome.

You just wanted to welcome me by commenting or do you really know the solution ??

This is what i get from get issue. 


{

"customfield_12904": [

{

"accountId": "123111515",

"emailAddress": "abc@abc.com",

"displayName": "abc",

"active": true,

"timeZone": "Etc/GMT",

"accountType": "atlassian"

}

]

}
Pramodh M
Community Champion
February 10, 2022

Here it is

Use this as a sample and let me know if it works

curl --request PUT \
--url 'https://your-site.atlassian.net/rest/api/3/issue/WSP-198' \
--user 'email:token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{ "fields": { "customfield_10082": [{"value": "Apple"}, {"value": "Mango"}]}}'

Thanks

Suggest an answer

Log in or Sign up to answer