It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage
Highlighted

Cannot add attachment when ticket creation using service desk API

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

DPK J Community Leader Dec 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?

Yes, I looked at it @DPK J . 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.

DPK J Community Leader Dec 13, 2019

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

Thanks @DPK J .  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.

DPK J Community Leader Dec 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.

Yeah sure. Thanks @DPK J 

hey @DPK J , any updates regarding the above incident?

DPK J Community Leader Dec 15, 2019

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

DPK J Community Leader Dec 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"]
}
}'

@DPK J  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"]}}
DPK J Community Leader Dec 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.

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

DPK J Community Leader Dec 16, 2019

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

Thats awesome @DPK J  

Hello @Arvind

 @DPK J 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
Community showcase
Published in Jira Service Desk

The Complete Guide to Atlassian for ITSM

Hi Atlassian Community! This is Teresa from the Atlassian team. My colleague Paul Buffington @Buff and I are excited to share a brand new ITSM resource we’ve created – "The Complete Guide to At...

1,118 views 7 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you