Jira Cloud fields and work types
Jira multi user picker custom field: set via API
The multiple users picker takes an array of {"accountId": ...} objects and returns an array of user objects. Edit metadata allows add, set and remove, so a person can be added without resending the list.
Endpoints
| Method | Path | What it does |
|---|---|---|
PUT | /rest/api/3/issue/{issueIdOrKey} | Sets or changes the value. |
GET | /rest/api/3/issue/{issueIdOrKey} | Reads the stored value. |
GET | /rest/api/3/issue/{issueIdOrKey}/editmeta | Lists what can be edited. |
Examples
PUT /rest/api/3/issue/{issueIdOrKey}
Sets a list with one user.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10174": [
{
"accountId": "<accountId>"
}
]
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10174'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10174',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'customfield_10174'},
json={'fields': {'customfield_10174': [{'accountId': '<accountId>'}]}},
)
print(r.status_code, r.text)Response: HTTP 200
{
"key": "ZZREF-6",
"fields": {
"customfield_10174": [
{
"self": "https://your-domain.atlassian.net/rest/api/3/user?accountId=<accountId>",
"accountId": "<accountId>",
"emailAddress": "<email>",
"avatarUrls": {
"48x48": "<avatar url>",
"24x24": "<avatar url>",
"16x16": "<avatar url>",
"32x32": "<avatar url>"
},
"displayName": "<display name>",
"active": true,
"timeZone": "Europe/Bucharest",
"accountType": "atlassian"
}
]
}
}Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
A single object in place of the array is refused.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10194": {
"accountId": "<accountId>"
}
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10194'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10194',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'customfield_10194'},
json={'fields': {'customfield_10194': {'accountId': '<accountId>'}}},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [],
"errors": {
"customfield_10194": "data was not an array"
}
}Sent to Atlassian Cloud on .
GET /rest/api/3/issue/{issueIdOrKey}
Reading returns the array of user objects.
curl
curl -G \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
--data-urlencode 'fields=customfield_10162,customfield_10163,customfield_10164,customfield_10165,customfield_10166,customfield_10167,customfield_10168,customfield_10169,customfield_10170,customfield_10171,customfield_10172,customfield_10173,customfield_10174,customfield_10175,customfield_10176,customfield_10177,customfield_10178,customfield_10179,customfield_10180,customfield_10181' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'fields': 'customfield_10162,customfield_10163,customfield_10164,customfield_10165,customfield_10166,customfield_10167,customfield_10168,customfield_10169,customfield_10170,customfield_10171,customfield_10172,customfield_10173,customfield_10174,customfield_10175,customfield_10176,customfield_10177,customfield_10178,customfield_10179,customfield_10180,customfield_10181'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"key": "ZZREF-6",
"fields": {
"customfield_10174": [
{
"accountId": "<accountId>",
"displayName": "<display name>",
"active": true,
"timeZone": "Europe/Bucharest",
"accountType": "atlassian"
}
]
}
}Sent to Atlassian Cloud on .
GET /rest/api/3/issue/{issueIdOrKey}/editmeta
Edit metadata lists add, set and remove and the autoCompleteUrl.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"fields": {
"customfield_10174": {
"name": "zz-ref multiuser",
"autoCompleteUrl": "https://your-domain.atlassian.net/rest/api/1.0/users/picker?fieldName=customfield_10174&showAvatar=true&query=",
"operations": [
"add",
"set",
"remove"
]
}
}
}Sent to Atlassian Cloud on .
How it behaves
- Type key com.atlassian.jira.plugin.system.customfieldtypes:multiuserpicker, searcher key com.atlassian.jira.plugin.system.customfieldtypes:userpickergroupsearcher, schema type array with items user, display name "User Picker (multiple users)".
- [{"accountId": "<accountId>"}] answered 200 with an array holding one user object.
- {"accountId": ...} without the array gave 400 "data was not an array", keyed by the field id.
- Edit metadata shows operations add, set and remove.
Pitfalls
- The message for a single object is "data was not an array", a different wording from the multi-select field's.
- Setting with fields replaces the full list.
- The same searcher serves single and multiple user pickers, so a JQL search by user behaves the same way for both.
Questions and answers
Which operations does the multi user picker support?
Add, set and remove, according to edit metadata.
Related
- User picker (single user)
- Group picker (multiple groups)
- Select list (multiple choices)
- Reading field values: names, schema, v2 and v3
- Which fields can be set: editmeta and createmeta