Forums

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

How to define request type via API ticket creation?

Brady Buttrey
Contributor
October 14, 2024

So I am currently creating tickets through the API using the Issues post endpoint. I have everything set right and the ticket is created as a service request. But I want to select a certain service request type, like "General Service Request", but i can't seem to figure out how I can do that using the API. Does anyone know how this is done? I keep seem that it's a customfield, but if it is, it doesn't appear the same when inspected. 

4 answers

1 vote
Vijay Dadi
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.
October 15, 2024

Hello,

Every request type has its own ID which you can see it in the URL while you are editing the request type.

In you JSON body, you can mention the json value as 

 

"customfield_16024":"145" (in this case it corresponds to one of request type in my project.
Hope this helps!
Vijay
1 vote
Kishan Sharma
Community Champion
October 14, 2024

Hi @Brady Buttrey 

Below article explains the JSON data required to set the customer request type when creating a Jira Service Management request using the Jira (/rest/api/2/issue or /rest/api/3/issue) endpoint in Cloud.

How to set the Request Type when creating an issue using Jira REST API in Atlassian Cloud 

1 vote
Ashok Shembde
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.
October 14, 2024

Hi @Brady Buttrey ,

Use the value customfield_XXXXX and REQUEST_TYPE_ID to correctly set the request type in your API call for creating Jira tickets.

0 votes
Eduardo
Contributor
October 14, 2024

To define a request type (such as "General Service Request") when creating a ticket via Jira's API, you need to ensure that you are setting the correct request type in the API request. This is typically done using the requestTypeId field, but it's not as straightforward as using a custom field in the issue creation payload. Here's how to proceed:

Steps to Set Request Type via API:

  1. Find the Request Type ID: You need the requestTypeId corresponding to the "General Service Request" type. This ID can be retrieved via the Jira Service Desk REST API.

    • Use this endpoint to list all available request types for a given service desk:
      GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttype
      This will return all request types associated with a given service desk, including their IDs and names.
  2. Use the Correct API Endpoint: When creating a Jira Service Management (formerly Jira Service Desk) ticket, you need to use the Jira Service Management API, not just the Jira Core issue creation API. The endpoint to use is:

    POST /rest/servicedeskapi/request
  3. Payload Structure: In the payload, you need to specify both the requestTypeId and the serviceDeskId (the ID of the service desk the request type belongs to).

    Here's an example payload to create a request of type "General Service Request":

    {
      "serviceDeskId": "1",  // The ID of your service desk
      "requestTypeId": "37", // The ID of the request type (e.g., General Service Request)
      "raiseOnBehalfOf": "customer@example.com", // Optional: the email of the customer
      "requestFieldValues": {
        "summary": "This is a general service request",
        "description": "Detailed description of the issue"
      }
    }
    
    • serviceDeskId: The ID of the service desk where the request is being raised.
    • requestTypeId: The ID of the request type, which you retrieved from the API in step 1.
    • raiseOnBehalfOf: (Optional) You can raise the request on behalf of another customer if needed.
    • requestFieldValues: This contains the fields of the issue (summary, description, etc.).

Example: Getting the Request Type ID

To get the requestTypeId for "General Service Request", use the following API request:

curl -u your-email:your-api-token \
  -X GET \
  -H "Content-Type: application/json" \
  https://your-domain.atlassian.net/rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttype

This will return a list of all request types and their IDs. Find the one named "General Service Request" and note its id.

Important Notes:

  • The Jira Core issue creation API (/rest/api/3/issue) does not support setting the request type directly. It only creates generic issues, so you need to use the Service Management API.
  • Ensure that your API token and user have the necessary permissions to create requests in the specified service desk.

Let me know if you need further clarification or help with this!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events