Setting the Requst Type of a newly created Issue via remote API

Peter Androutsos June 26, 2019

I have been able to successfully create an issue using the REST api (rails gem) on my JIRA Service Desk instance (cloud).  I have also been successful in setting the reporter, but I have noticed that although the customer has been set, the issue does not show up on the customer's request list.  I readily figured out that the problem is that the request type was not being set.

 

The project that I am using has the issue type mapped to a specific request type.  Furthermore, the Request Type field has been added to the create issue screen.  In addition, I have manually set another issue to include the appropriate request type, and determined the request type field to be 'customfield_10047'.  

 

With all this said, I have been very unsuccessful in setting the Request Type during creation.  The first semi-sucessful attempt resulted in the following error:

 

errors:

    customfield_10047: Operation value must be a string

 

 

This occurred when I was passing more complex information about the request type (so as to mirror an existing issue).

After this, the closest I managed to getting a semi-valid response is when the server was when using a pure string.  In this case, the server responded with:

 

errors:

    customfield_10047: Invalid customer request value

 

 

I've tried setting the string value to the id of the request type "97", and I've also tried setting it to the exact string value of the Request Type, namely "Purchase Request", but no matter what I enter, I get an error.

 

Any ideas on how this value can be set appropriately?

 

4 answers

1 accepted

6 votes
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 2, 2019

Hi @Peter Androutsos ,

It  took a bit of research and testing but I am happy to say I managed to make this work in Jira Cloud as well. Also, I am adding this as a new answer so that if you like it you can accept it as the solution for this question.

The way to achieve what you are asking for is actually explained in below KB for Jira Server:

 

However, since in Cloud you do not have access to the Database, you cannot get the request type KEY from the  AO_54307E_VIEWPORTFORM table as explained in above KB, but you will have to use the following REST API endpoint instead:

  • https://YOUR_HOSTNAME/rest/servicedesk/SERVICE_DESK/servicedesk/request/ISSUE/request-types

Calling to the above endpoint (or pasting it in the browser) with a correct issue ID and the correct service desk ID for the associated issue will result in JIRA returning a JSON response containing all customer request types within the service desk, including the Key.

 

Please notice that this is an internal endpoint not officially documented that can change without prior notice. Indeed we have the below Feature request opened in our system to have the official REST API endpoint to include the request-type key to which I have just added the workaround:

 

You may want to vote and watch the above feature request so that you will get notified in case of any update. The  feature will be addressed according to the Implementation of New Features Policy.

 

Let me know if this helps.

 

Cheers,
Dario

Peter Androutsos July 3, 2019

This is helpful.  I will explore these options and endpoints.

Like Dario B likes this
Linwood Ma August 16, 2019

Agreed - helpful.

Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 20, 2019

Thanks for letting me know @Linwood Ma ! :) 

Also, just FYI, I have summarized everything in the below KB article:

 

Cheers,
Dario

CrushedLive June 8, 2020

I didn't have any luck using the API to get the keys so instead, I exported my cloud instance and found the /backup/data[@tablename='AO_54307E_VIEWPORTFORM'] node in the activeobjects.xml file.

This node contains all the rows from the AO_54307E_VIEWPORTFORM table, where you should find the KEY column. The column should be the 7th entry in the row node and will be either a string like "getithelp" or a GUID.

pavol_cvincek01 May 10, 2021

Hello @Dario B ,
Thank you for this link:
https://confluence.atlassian.com/jirakb/how-to-set-request-type-when-creating-an-issue-via-rest-api-using-rest-api-2-issue-endpoint-938041214.html

There is one thing I would need to explain bit more:
"You'll just have to identify the custom field id and valid values and you should use for it to work."

Long story short, I am working on Integration from OpsGenie to Jira where I need to create tickets in Jira based on Alerts from OpsGenie. The problem is that "Customer request type" is set to "Service Request" and we need "Incident"

my custom field for this setting is "customfield_13040" but what I don't know is valid values. When I put there "fixit/alerts" it works but it's creating Service Requests, not Incidents as desired. I don't know where and how to look it up.
Can you please advice?

Jira version if needed: Jira v8.5.5

pavol_cvincek01 May 10, 2021

I was able to solve this problem. Please ignore

Like Dario B likes this
0 votes
felix.weber June 22, 2021

For all of you facing 404 errors please make sure you are using the IssueID not the IssueKey !

see also here => https://jira.atlassian.com/browse/JSDCLOUD-4917?focusedCommentId=2490016&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2490016

0 votes
harsh kanukuntla September 12, 2019

Hi @Dario B ,

I tried to follow your guide but i am still unable to get the Customer Request Type field's allowed value list.

I am working on Jira Cloud and i am trying to create a ticket using Google Scripting and trying to Populate the Customer Request Type field with an existing category 'Testing & Management' and my script returns "customfield_10800":"Invalid customer request value" error.

 

My project key is "Test" and i tried using the endpoint "rest/servicedesk/SERVICE_DESK/servicedesk/request/ISSUE/request-types" but it doesn't display anything on the screen.

 

Any help is highly appreciated.

harsh kanukuntla September 12, 2019

@Dario B , i get a 404 when trying to access the below endpoint.

Service-Desk ID: 2

Issue-Id: 10201


/rest/servicedesk/2/servicedesk/request/10201/request-types

Is there any other way to view the Key?

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 17, 2019

@harsh kanukuntla ,

The endpoint seem to have changed and now it is: 

  • https://YOUR_HOSTNAME/rest/servicedesk/1/servicedesk/request/ISSUE_ID/request-types

 

Also, the below KB has been updated in order to reflect the change:

 

However, please once again notice that you should be using the Jira Service Desk Cloud REST API /rest/servicedeskapi/request instead of the Jira Core Cloud REST API endpoint  /rest/api/2/issue:

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 28, 2019

Hi @Peter Androutsos ,

In order to create a valid customer request in Jira Service Desk Cloud you may want to use the Jira Service Desk REST API endpoint /rest/servicedeskapi/request instead of the Jira Core Rest API endpoint /rest/api/2/issue (or /rest/api/3/issue).

 

For further details please see:

I hope this helps.

 

Have a nice weekend.

 

Cheers,
Dario

Peter Androutsos June 28, 2019

Thanks.  I've since added some automation in the project which provides a workaround to this, but I will investigate trying to do this the other way around regardless.  With that said, I am curious as to why the option to set the request type exists on the regular issue-generating api, but won't accept any value.  Are there specifics to what values can be set for this parameter?

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 3, 2019

@Peter Androutsos ,

The actual problem is not that it does not accept any value, but that the value you are supposed to enter in there is not documented and not exposed by public APIs. For this I have added an howto/workaround yesterday.

However, can you kindly let us know the use case for which you need to call the Jira Core REST API endpoint to create the issue and you cannot use the Servicedesk ones, so that I can forward this feedback to the Jira Service Desk team?  

 

Thanks,
Dario

Suggest an answer

Log in or Sign up to answer