How to create issues with Assets Custom Field using Jira Service Management API
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Summary
The purpose of this article is to help us with the syntax to create customer issues with Assets custom fields using Jira Service Management API.
Solution
This article applies to Atlassian apps on the cloud platform. To create a customer request with an Assets custom field, use the Jira Service Management API and provide the Assets object values workspaceId and objectId attributes.
Use these API calls to fetch the values required by the request:
Fetch the
workspaceIdwithGET https://<JSM Premium Site Name>.atlassian.net/rest/servicedeskapi/insight/workspace.Fetch the
objectIdwithhttps://api.atlassian.com/jsm/insight/workspace/{workspaceid}/v1/iql/objects.Fetch the
serviceDeskIdwithGET https://your-domain.atlassian.net/rest/servicedeskapi/servicedesk.Fetch the
requestTypeIdwithGET https://your-domain.atlassian.net/rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttype.
This example uses an OAuth Bearer token; the same Jira Service Management REST API endpoint also accepts Basic authentication using your account email and an API token, which may be simpler to setup for a one-off script.
Syntax:
curl --request POST \
--url 'https://your-domain.atlassian.net/rest/servicedeskapi/request' \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"requestParticipants": [
"qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d69abfa3980ce712caae"
],
"serviceDeskId": "10",
"requestTypeId": "25",
"requestFieldValues": {
"summary": "Request JSD help via REST",
"description": "I need a new *mouse* for my Mac"
"customfield_10101" : [{"id": "{workspaceid}:{objectid}", "objectId": "{objectid}", "workspaceId": "{workspaceid}"}]
}
}'In the Assets custom field value, replace {workspaceid} and {objectid} with the relevant values. The id value uses the format {workspaceid}:{objectid}.
We can fetch the "workspaceId" by using the GET API call: https://<JSM Premium Site Name>.atlassian.net/rest/servicedeskapi/insight/workspace
The "objectId" can be fetched using the API call: https://api.atlassian.com/jsm/insight/workspace/{workspaceid}/v1/iql/objects
The "ServiceDeskId" can be fetched using the GET API call: https://your-domain.atlassian.net/rest/servicedeskapi/servicedesk
The "requestTypeId" can be fetched using the GET API call: https://your-domain.atlassian.net/rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttype
Was this helpful?