Forums

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

Programmatic Service Request Creation - Request Type Not Being Applied (JSM API Python 'jira')

gastori February 17, 2025

 

 

We are attempting to programmatically create Service Requests in our Jira Service Management project (Project Key: [YOUR_JIRA_PROJECT_KEY], Service Desk ID: [YOUR_JIRA_SERVICE_DESK_ID]) using the Python jira library (official Jira Python client).

Our Goal:

We need to automate the creation of Service Requests with a specific Request Type within our Jira Service Management project. For example, we have a Request Type named '[YOUR_REQUEST_TYPE_NAME, e.g., MDC]' (Request Type ID: [YOUR_REQUEST_TYPE_ID, if you found it, e.g., from API script output]).

What We Have Tried and What is Working:

  • We are successfully connecting to our Jira instance using basic authentication (username/password) with the Python jira library.
  • We can programmatically create basic Jira issues in the target JSM project. These issues are created with the correct Project and Issue Type ("Service Request" or "[System] Service request").
  • However, when we attempt to set the Request Type during issue creation using the serviceDeskId and requestTypeName (or requestTypeId) parameters in the jira.create_issue() method, the issue is created successfully, but the specified Request Type is not applied to the newly created issue. It defaults to a generic Service Request without the specific Request Type we intended.

The Problem/Challenge:

Despite including the serviceDeskId and requestTypeName (or requestTypeId) parameters in our jira.create_issue() call, the Request Type is consistently not being applied. We have tried:

  • Using the Request Type Name
  • Using the Request Type ID
  • Ensuring the correct serviceDeskId for our JSM project is being used.
  • Verifying that the user account we are using for API access has "Create Issues" permissions in the target project and appropriate Customer Permissions in the JSM project.

We are using the following structure in our Python code for issue creation (simplified example):

from jira import JIRAa # ... (Jira connection setup with basic_auth) ... issue_dict = { 'project': {'key': '[YOUR_JIRA_PROJECT_KEY]'}, 'issuetype': {'name': '[System] Service request'}, # or 'Service Request' 'summary': 'Test Service Request Creation with Request Type', 'description': 'Programmatic test...', } new_issue = jira.create_issue( fields=issue_dict, serviceDeskId='[YOUR_SERVICE_DESK_ID]', requestTypeName='[YOUR_REQUEST_TYPE_NAME]' # OR requestTypeId='[YOUR_REQUEST_TYPE_ID]' )

1 answer

0 votes
Lucas Modzelewski _Lumo_
Atlassian Partner
February 17, 2025

Hi @gastori , welcome to the Atlassian Community!

Are you using the correct endpoint for JSM? 

'url = "https://your-domain.atlassian.net/rest/servicedeskapi/request" '

JSM API is different from the general Jira API, and using wrong endpoints might result in fallback to defauls

Check the docs: https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-post 

gastori February 17, 2025

I am using the Jira Python module https://jira.readthedocs.io/index.html. I am not invoking Jira Rest API.
Should I use the native Resat API?

Lucas Modzelewski _Lumo_
Atlassian Partner
February 17, 2025

In my opinion in general it is better to go to the source. Especially since there are python examples in docs. You won't be limited by the library and get access to latest api.

I've asked chat GPT about hints to solve this and this is the part of the reply (but verify it yourself):

Important Notes:

1️⃣ Use /rest/servicedeskapi/request instead of the standard Jira issue creation endpoint.

2️⃣ The jira library does not natively support JSM request creation, so you need to use jira._session.post().

3️⃣ Make sure your user has the correct permissions to create requests in JSM.

4️⃣ Always test with a small request before automating in production.

gastori February 17, 2025

Thanks. I think I go with the native Rest API to get a better support and latest updates. I just hate to deal with assembly the https payload. A python module simplifies the code by abstracting all the raw constructs.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events