Many of our Jira Service Desk Project's request types use dedicated forms to show or hide fields based on previous selections on the form. I need to be able to create customer requests through the REST API.
I used to be able to do this by ignoring the form and including the necessary fields under 'requestFieldValues', but something changed in the past several months that prevents me from doing this anymore (I think that fields can no longer be included in the request type if they exist in the attached form).
I can see POST Create Customer Request in the documentation, which should allow me to provide form fields but its unclear based on the documentation what is required for the field IDs, are these in the format of 'customfield_12345' or just '12345', or does each form have have an arbitrary number assigned to each field (how would I get this)? It's also unclear if I can provide the choice IDs, or if it prefers the text value of the selection. Choices are required as a array, what if the field only allows a single choice, is it OK to supply an array with a single value for those field types?
I have tried a variety of different variations, but I always get the same response: 'This request is invalid. Check that the request contains all the required parameters and that the parameters are valid.'
Example payload I am trying:
We did manage to figure this out though not without some difficulty. There may be a more efficient way to get the form questions/answers, but I'll outline below how we worked through the problem.
I don't think I found a dedicated API call to get a form's questions directly, but it is possible to reverse engineer the questions from a manually filled and submitted form.
POST https://{yourOrgValue}.atlassian.net/rest/servicedeskapi/request
{
"serviceDeskId": "123",
"requestTypeId": "456",
"raiseOnBehalfOf": "ATLASSIAN_USER_ID",
"isAdfRequest": false,
"requestFieldValues": {
"customfield_12345": "TEXTVALUE"
},
"form": {
"answers": {
"8": {
"text": "TEXTVALUE"
},
"7": {
"choices": [
"81992"
]
},
"14": {
"text": "TEXTVALUE"
},
"30": {
"users": [
"ATLASSIAN_USER_ID"
]
}
}
}
}
Hope this helps. It's a bit of a mess to translate everything manually, but in the end it worked for us.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.