Forums

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

Trying to set people custom field via JIRA REST API

Philip Colmer
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 11, 2017

I want to set the list of people on a custom field using the JIRA REST API.

According to https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue, the syntax for setting a UserPicker is:

"customfield_10017": { "name":"brollins" } 

and according to https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/updating-an-issue-via-the-jira-rest-apis, the JSON sent needs to specify an update followed by the fields.

So, the JSON I'm sending is:

{
    'update': {
        'fields':
        {
            'customfield_10800': [{'name': 'fred.bloggs@example.com'}]
        }
    }
}

However, when I try to PUT this to the issue, I get the following message back:

Unexpected character (\'u\' (code 117)): expected a valid value (number, String, array, object, \'true\', \'false\' or \'null\')\\n at [Source: org.apache.catalina.connector.CoyoteInputStream@228b27b5; line: 1, column: 2]

Now, according to https://docs.atlassian.com/jira/REST/server/#api/2/issue-editIssue, fields should appear either in "fields" or "update" not in both. If I remove the "update" section, the error message changes to:

"Unrecognized token \'fields\': was expecting \'null\', \'true\', \'false\' or NaN\\n at [Source: org.apache.catalina.connector.CoyoteInputStream@228b27b5; line: 1, column: 8

I've tried double and single quotes.

I've run out of ideas :)

What have I got wrong in the data that I'm sending?

 

1 answer

1 accepted

3 votes
Answer accepted
Sam Hall
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 11, 2017 edited

Assuming you are using a multi-user picker field, the following JSON should work:

{ "fields": {"customfield_10800": [{"name": "admin"}]} }

 

Sam Hall
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 11, 2017 edited

To set more than one user, you can do:

{ "fields": {"customfield_10800": [{"name": "admin"},{"name" : "philip.colmer"}]} }

Like • 2 people like this
Philip Colmer
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 12, 2017

Sorry, Sam, but if I try using that, I get this error:

Unrecognized token \'fields\': was expecting \'null\', \'true\', \'false\' or NaN\\n at [Source: org.apache.catalina.connector.CoyoteInputStream@21ab85b3; line: 1, column: 8
Philip Colmer
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 12, 2017

Hmm ... I've just retried this by using curl and it has worked so clearly I'm doing something wrong with the code.

Thanks for confirming the correct format.

 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence, loom, atlassian intelligence, ai notes, ai-powered meeting notes, atlassian community events, ace, confluence ai, loom ai integration, ai note-taking, atlassian ai features, team '25, atlassian live learning, confluence automation

Unlock AI-powered meeting notes: Join our live learning session! 📹

Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.

Register today!
AUG Leaders

Atlassian Community Events