Rest API | custom field format for single-user and multiple-user is out-of-date

Description:
I want to create a customer request (or you can say “an issue”) with the custom fields (single-user picker custom field and multi-user picker custom field).

Rest API endpoint: POST /rest/servicedeskapi/request

Custom fields:

  • single-user picker type
  • multi-user picker type

Refer to the Field Input Formats doc, the format should be:

According to the release note, “name” and “key” are deprecated from User schema, “accountId” is recommended to be used in all place.

I tested either use “name”, “id” or “accountId” as the key for the single-user and multi-user custom input fields, raise 400 error or return 200 but these custom fields don’t have value. I attached the results below:



Question: what’s the correct input field format for these two custom fields?

Welcome to the Atlassian developer community @DevChannels,

Each of the docs to which you refer is a different platform. The REST endpoint docs are for JSM Cloud. The Field Input Formats is about JSM Data Center (and it’s equivalent JSM Server). Those have different REST APIs. Which will you be using?

Hi @ibuchanan , I am using JSM Cloud, need to Create a Request with single-user picker and multi-user picker custom fields.

@DevChannels,

How odd. The following works for me:

{
  "serviceDeskId": "9",
  "requestTypeId": "131",
  "requestFieldValues": {
    "summary": "Change request via REST",
    "description": "I want to install Brew on my Mac",
    "customfield_10598": {
      "accountId": "557057:3d0e64ae-35d3-490d-b6d9-d81c981476d0"
    },
    "customfield_10300": [
      {
        "id": "557057:3d0e64ae-35d3-490d-b6d9-d81c981476d0"
      }
    ]
  }
}

Both id and accountId work interchangeably.

customfield_10598 is a single-user picker. It works with either the account object alone, or with a single valued array with the account object.

Conversely, customfield_10300 is a multi-user picker. It only works with an array, but it takes even an empty array.

If the field is hidden from the request form, then I get the same status code (400 Bad Request) but a different error message:

{
  "errorMessage": "Unable to create request because of these errors : The field 'customfield_10598' is not valid for this request type 'Request a change'.",
  "i18nErrorMessage": {
    "i18nKey": "sd.request.create.error.failed.msg",
    "parameters": [
      "The field 'customfield_10598' is not valid for this request type 'Request a change'."
    ]
  }
}

Or, if I use an invalid accountId (still 400 status):

{
  "errorMessage": "Unable to create request because of these errors : Field with id 'customfield_10598' named 'Pick me' has these errors : Specify a valid value for customfield_10598",
  "i18nErrorMessage": {
    "i18nKey": "sd.request.create.error.failed.msg",
    "parameters": [
      "Field with id 'customfield_10598' named 'Pick me' has these errors : Specify a valid value for customfield_10598"
    ]
  }
}

I cannot reproduce the error you’re seeing. Moreover, looking only at your request payload, I cannot see anything different in the field formats that would be a problem.

Thanks @ibuchanan for testing it out!
Compare our payloads, the value format of accountId are different. Your accountId is 557057:3d0e64ae-35d3-490d-b6d9-d81c981476d0, my accountId is 61fa7a56f5f5b80070c78e2c. This maybe the root cause. How did you get the accountId?

Reproduce steps:

  1. Create a request which contains the single_user_picker and multi_user_picker custom fields in Jira Service Management UI.
  2. Fill values for these two fields in this request on UI.
  3. Read this request by Postman (GET /rest/servicedeskapi/request/{{issueIdOrKey}}). I got below response.
......
        {
            "fieldId": "customfield_10784",
            "label": "rtm_custom_user_picker_single_user",
            "value": {
                "self": "https://az-dev.atlassian.net/rest/api/2/user?accountId=61fa7a56f5f5b80070c78e2c",
                "accountId": "61fa7a56f5f5b80070c78e2c",
                "avatarUrls": {
                    "48x48": "https://secure.gravatar.com/avatar/c0204e3188127149a40195fbbd4f8bfa?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFL-6.png",
                    "24x24": "https://secure.gravatar.com/avatar/c0204e3188127149a40195fbbd4f8bfa?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFL-6.png",
                    "16x16": "https://secure.gravatar.com/avatar/c0204e3188127149a40195fbbd4f8bfa?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFL-6.png",
                    "32x32": "https://secure.gravatar.com/avatar/c0204e3188127149a40195fbbd4f8bfa?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFL-6.png"
                },
                "displayName": "first14 last14",
                "active": true,
                "timeZone": "America/Los_Angeles",
                "accountType": "atlassian"
            }
        },
        {
            "fieldId": "customfield_10783",
            "label": "rtm_custom_user_picker_multiple_users",
            "value": [
                {
                    "self": "https://az-dev.atlassian.net/rest/api/2/user?accountId=61fa7a56f5f5b80070c78e2c",
                    "accountId": "61fa7a56f5f5b80070c78e2c",
                    "avatarUrls": {
                        "48x48": "https://secure.gravatar.com/avatar/c0204e3188127149a40195fbbd4f8bfa?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFL-6.png",
                        "24x24": "https://secure.gravatar.com/avatar/c0204e3188127149a40195fbbd4f8bfa?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFL-6.png",
                        "16x16": "https://secure.gravatar.com/avatar/c0204e3188127149a40195fbbd4f8bfa?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFL-6.png",
                        "32x32": "https://secure.gravatar.com/avatar/c0204e3188127149a40195fbbd4f8bfa?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFL-6.png"
                    },
                    "displayName": "first14 last14",
                    "active": true,
                    "timeZone": "America/Los_Angeles",
                    "accountType": "atlassian"
                },
                {
                    "self": "https://az-dev.atlassian.net/rest/api/2/user?accountId=61fa7ad2f5f5b80070c78e5e",
                    "accountId": "61fa7ad2f5f5b80070c78e5e",
                    "avatarUrls": {
                        "48x48": "https://secure.gravatar.com/avatar/e5570dab7d159f4f389fb10dad6d11f1?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRJ-6.png",
                        "24x24": "https://secure.gravatar.com/avatar/e5570dab7d159f4f389fb10dad6d11f1?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRJ-6.png",
                        "16x16": "https://secure.gravatar.com/avatar/e5570dab7d159f4f389fb10dad6d11f1?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRJ-6.png",
                        "32x32": "https://secure.gravatar.com/avatar/e5570dab7d159f4f389fb10dad6d11f1?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRJ-6.png"
                    },
                    "displayName": "rubin jin",
                    "active": true,
                    "timeZone": "America/Los_Angeles",
                    "accountType": "atlassian"
                },
                {
                    "self": "https://az-dev.atlassian.net/rest/api/2/user?accountId=61fa7ad9530d2a00714713b1",
                    "accountId": "61fa7ad9530d2a00714713b1",
                    "avatarUrls": {
                        "48x48": "https://secure.gravatar.com/avatar/0b849ba56780beb3e8fb1627e3d7f088?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTL-6.png",
                        "24x24": "https://secure.gravatar.com/avatar/0b849ba56780beb3e8fb1627e3d7f088?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTL-6.png",
                        "16x16": "https://secure.gravatar.com/avatar/0b849ba56780beb3e8fb1627e3d7f088?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTL-6.png",
                        "32x32": "https://secure.gravatar.com/avatar/0b849ba56780beb3e8fb1627e3d7f088?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTL-6.png"
                    },
                    "displayName": "test4 last5",
                    "active": true,
                    "timeZone": "America/Los_Angeles",
                    "accountType": "atlassian"
                }
            ]
        },
......
  1. Copy the accountId to the create_request request body, call the API by Postman (POST /rest/servicedeskapi/request). The request body is as blow:
{
    "requestFieldValues": {
        "summary": "test bug 2",
        "customfield_10784": {
            "accountId": "61fa7a56f5f5b80070c78e2c"
            }
        },
    "serviceDeskId": "19",
    "requestTypeId": "203"
}

Got 400 error.

{
    "errorMessage": "Your request could not be created. Please check the fields have been correctly filled in. Please provide a valid value for field 'rtm_custom_user_picker_single_user'",
    "i18nErrorMessage": {
        "i18nKey": "sd.validation.request.creation.failure.required.field",
        "parameters": [
            "Please provide a valid value for field 'rtm_custom_user_picker_single_user'"
        ]
    }
}

Hi @ibuchanan any update?

By itself, that doesn’t mean much. My id in Atlassian identity was created when the service first came on line, so that’s the “original format”. A new account will no longer have a : segment in the front. If you think there might be something about your account id, it would be best to pursue that with developer support. Privacy policies prevent me from just going from this public thread to “look you up”. We need the traceability of a support case. As such, it’s pretty typical for auth problems to end up needing to go to support.

However, this isn’t auth and I trust how you obtained your own id. Per my experiments, a wrong id would give us a different error. I wonder if it’s a configuration problem. Could you try using the 2 custom field ids from my response? Both are out-of-the-box custom fields (weird, right?) so they exist in every new Jira instance. Maybe there’s something about your new custom field or how it’s configured for that request/issue type that is the problem?