Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cannot add attachment when ticket creation using service desk API

Arvind December 12, 2019

I need to create a ticket with an attachment so that I am using a service desk API to create a ticket. I am able to add an attachment using temporary attachment API

/rest/servicedeskapi/servicedesk/{serviceDeskId}/attachTemporaryFile

It returns

temporaryAttachmentId: 'some unique id'

 When I send this temporaryAttachmentId to the ticket creation API

url: /rest/servicedeskapi/request 
body params: 
{
"raiseOnBehalfOf":"user",
"serviceDeskId":"x",
"requestTypeId":"xxx",
"requestFieldValues":
{
"attachment":["temporaryAttachmentId"]
}
}

the API returns

{"errorMessage":"Your request could not be created. Please check the fields have been correctly filled in. Please reattach all the currently listed attachments","i18nErrorMessage":{"i18nKey":"sd.validation.request.creation.failure.required.field","parameters":["Please reattach all the currently listed attachments"]}}

Why isn't the temporary attachment is not recognized by JIRA when the temporary attachment upload was successful?

2 comments

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 12, 2019

@Arvind  Have you take look at this documentation - https://confluence.atlassian.com/jirakb/how-to-add-an-attachment-to-a-jira-service-desk-cloud-ticket-using-the-rest-apis-917967216.html

Also, have you tried creating 'Request' first and then using 'attachment' api to add attachment?

Arvind December 13, 2019

Yes, I looked at it @DPKJ . I know that it will work if we first create request and add an attachment using 'attachment' API. But in my case, the form has a mandatory attachment. So the request will not be created if the attachment is missing.

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 13, 2019

Oh! Let me check on my system, if JSD Cloud allow this.

Arvind December 13, 2019

Thanks @DPKJ .  We are facing this exception occasionally.  Only sometimes we receive this exception that

"Please reattach all the currently listed attachments

There is not a pattern to find the root-cause.  We tested the file attachment with the same type of files that received this exception.  The attachment was attached successfully.

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 13, 2019

Give me some time @Arvind  I will try and find some time in weekend to run this experiment. Hopefully, I might come up with some solutions.

Arvind December 13, 2019

Yeah sure. Thanks @DPKJ 

Arvind December 15, 2019

hey @DPKJ , any updates regarding the above incident?

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 15, 2019

@Arvind  I'm on it, weekend was busy!

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 16, 2019

@Arvind  This code seems to be working fine for me.

#!/bin/bash

curl --request POST \
--url https://<SITE>.atlassian.net/rest/servicedeskapi/servicedesk/1/attachTemporaryFile \
--user '<EMAIL>:<TOKEN>' \
--header 'X-Atlassian-Token: nocheck' \
--header 'X-ExperimentalApi: opt-in' \
-F 'file=@"./temp.txt"'

## Once you get ID from above, use it in below


curl --request POST \
--url 'https://<SITE>.atlassian.net/rest/servicedeskapi/request' \
--user '<EMAIL>:<TOKEN>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"serviceDeskId": "1",
"requestTypeId": "1",
"requestFieldValues": {
"summary": "Request JSD help via REST",
"description": "I need a new *mouse* for my Mac",
"attachment": ["77257341-bd38-43a2-9b39-0a6521eabca1"]
}
}'
Arvind December 16, 2019

@DPKJ  yes this is what I am doing, it was working fine for me too. The problem here is it was not working some times. We can't able to find the scenario and root cause for this. Once It is failed I reattach the same file and create a ticket, it was created and the attachment is successfully added.

 

Do you know the possibilities of getting the following error in the ticket creation API response

{"errorMessage":"Your request could not be created. Please check the fields have been correctly filled in. Please reattach all the currently listed attachments","i18nErrorMessage":{"i18nKey":"sd.validation.request.creation.failure.required.field","parameters":["Please reattach all the currently listed attachments"]}}
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 16, 2019

@Arvind  I think temporary attachments doesn't get listed sometimes, it can be some kind of race condition within Jira Cloud system.

I think you should contact Atlassian Support, and check with them if they can confirm this scenario.

Arvind December 16, 2019

Thanks for your support @DPKJ  . Can you point me to contact Atlassian support team.

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 16, 2019

Let me put this to Leaders Group, and request Atlassian Team to jump in.

Arvind December 16, 2019

Thats awesome @DPKJ  

Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 17, 2019

Hello @Arvind

 @DPKJ reached out to us to take a look at your question here and you guys are hitting a limitation in the Service desk API, as currently the Service desk add attachment API endpoint allows adding an attachment to an issue that has already been created but does not allow adding the attachment to the issue on the create action.  So your specific workaround would require removing the required attachment on the issue create action in the customer portal.

Looking at your API calls the initial add temporary attachment portion of your requests is correct however the follow up post needs to be to a direct issue ID via a:

POST https://INSTANCE.atlassian.net/rest/servicedeskapi/request/ISSUE_ID/attachment

There is some more information on this and we are collecting feedback on the following feature request, please make sure to add a vote to the request and add some details to the request on what your trying to do and how it is impacting you currently to help finalise the attachments REST API:

Regards,
Earl

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events