Forums

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

update a custom field from API REST

Valentino GARCIA MENDEZ July 4, 2024

Hello everyone, I'm trying to make a script automatically assign a person to a custom field but it's not working. What am I doing wrong?

url: xxxx.atlassian.net/rest/api/2/issue/GRD-1152

json content:

{ "fields": { "customfield_10280": "userId" } }

1 answer

0 votes
Magdalena Zhisheva
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.
July 4, 2024

Hi @Valentino GARCIA MENDEZ , 

 

Is the field a user picker (multiple users) or user picker (single user) type?

Moreover, do you have any other field or context where the user name/email is placed?
Basically, you can achieve this with automation, but you have to send Web Request like this:
"xxx.atlassian.net/rest/api/2/user/search?query={{[where the user name is placed].urlEncode}}"

and then to assign the user to your custom field, use this:

{{webResponse.body.first.accountid}}

Happy to help if you need more details!

BR, Maggie

Valentino GARCIA MENDEZ July 4, 2024

The field is a user selector and has these fields:
"customfield_10280": {
"self": "https://*****.atlassian.net/rest/api/3/user?accountId=*************ff80c38a63f7",
"accountId": "****:******-****-ff80c38a63f7",
"emailAddress": "*****@*****.com",
"avatarUrls": {
"48x48": "https://secure.gravatar.com/avatar/f75d5a8f7ae2aa6f848b963eb5eb3066?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FVM-5.png",
"24x24": "https://secure.gravatar.com/avatar/f75d5a8f7ae2aa6f848b963eb5eb3066?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FVM-5.png",
"16x16": "https://secure.gravatar.com/avatar/f75d5a8f7ae2aa6f848b963eb5eb3066?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FVM-5.png",
"32x32": "https://secure.gravatar.com/avatar/f75d5a8f7ae2aa6f848b963eb5eb3066?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FVM-5.png"
},
"displayName": "Valentino GARCIA MENDEZ",
"active": true,
"timeZone": "America/Argentina/Buenos_Aires",
"accountType": "atlassian"
}
Additionally, the editmeta is as follows:

"customfield_10280": {
"required": false,
"schema": {
"type": "user",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:userpicker",
"customId": 10280
},
"name": "Referente",
"key": "customfield_10280",
"autoCompleteUrl": "https://*****.atlassian.net/rest/api/1.0/users/picker?fieldName=customfield_10280&fieldConfigId=10482&projectId=10175&showAvatar=true&query=",
"operations": [
"set"
]
}

Magdalena Zhisheva
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.
July 4, 2024

Hi @Valentino GARCIA MENDEZ , 

Can you give some more context of what exactly you are trying to do with this field, i.e. are you trying to assign same user every time based on some conditions?

Like Valentino GARCIA MENDEZ likes this
Valentino GARCIA MENDEZ July 4, 2024

I am writing a Python script that, based on certain parameters, assigns that custom field to a person. To test how the PUT request would work, I am trying it out in Postman and it's not working for me yet. For now, I am always testing with the same accountID.

Valentino GARCIA MENDEZ July 4, 2024

im trying this:
{
"update": {
"customfield_10280": [
{
"set": [
{
"accountId": "712020:1e04ff52-bc5a-4d4d-9aee-fa8eba77718b"
}
]
}
]
}
}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events