Jira Cloud fields and work types
Jira user picker custom field: set by accountId via API
The user picker is set with {"accountId": ...} and returns a user object with accountId, displayName, active, timeZone and accountType. An accountId that does not belong to a user gives a 400 keyed by the field id.
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}
Assigns the field to a user by accountId.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10173": {
"accountId": "<accountId>"
}
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10173'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_10173',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'customfield_10173'},
json={'fields': {'customfield_10173': {'accountId': '<accountId>'}}},
)
print(r.status_code, r.text)Response: HTTP 200
{
"key": "ZZREF-6",
"fields": {
"customfield_10173": {
"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 well-formed accountId with no user behind it 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_10173": {
"accountId": "000000:00000000-0000-0000-0000-000000000000"
}
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10173'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_10173',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'customfield_10173'},
json={'fields': {'customfield_10173': {'accountId': '000000:00000000-0000-0000-0000-000000000000'}}},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [],
"errors": {
"customfield_10173": "Specify a valid value for customfield_10173"
}
}Sent to Atlassian Cloud on .
POST /rest/api/3/search/jql
Finds work items where the field is the calling user, using currentUser().
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"jql": "project = ZZREF AND \"zz-ref user\" = currentUser()",
"fields": [
"summary"
],
"maxResults": 2
}' \
'https://your-domain.atlassian.net/rest/api/3/search/jql'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/search/jql',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'jql': 'project = ZZREF AND "zz-ref user" = currentUser()',
'fields': ['summary'],
'maxResults': 2},
)
print(r.status_code, r.text)Response: HTTP 200
{
"issues": [
{
"key": "ZZREF-11"
}
],
"isLast": true
}Sent to Atlassian Cloud on .
GET /rest/api/3/issue/{issueIdOrKey}
Reading returns the user object, with the address and avatars redacted in this reference.
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_10173": {
"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 gives the operation set and an autoCompleteUrl for finding users.
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_10173": {
"name": "zz-ref user",
"autoCompleteUrl": "https://your-domain.atlassian.net/rest/api/1.0/users/picker?fieldName=customfield_10173&fieldConfigId=10356&projectId=10100&showAvatar=true&query=",
"operations": [
"set"
]
}
}
}Sent to Atlassian Cloud on .
How it behaves
- Type key com.atlassian.jira.plugin.system.customfieldtypes:userpicker, searcher key com.atlassian.jira.plugin.system.customfieldtypes:userpickergroupsearcher, schema type user, display name "User Picker (single user)".
- {"accountId": "<accountId>"} answered 200 with a user object that includes emailAddress and avatarUrls (redacted in this reference).
- An unknown accountId gave 400 "Specify a valid value for customfield_10173", and this message uses the field id, not the display name.
- Edit metadata carries an autoCompleteUrl for the users picker endpoint.
- "zz-ref user" = currentUser() matched the work item assigned in the field.
Pitfalls
- Do not send the user name or email; the working key is accountId.
- The message for an unknown account is generic and does not repeat the id that was sent.
- Pass only the accountId; the rest of the user object in the response is output.
Questions and answers
Which key identifies the user?
accountId. The runs sent {"accountId": ...} and the response echoed the same accountId.
Related
- User picker (multiple users)
- Group picker (single group)
- reporter
- Reading field values: names, schema, v2 and v3
- Which fields can be set: editmeta and createmeta