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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Service Desk API - Adding Attachment

We are wanting to add attachments to an existing service desk using the POST API from our React Native application.  We are only receiving back "JSON Parse error: Unexpected EOF" from the API.  here is our post:

const formData = new FormData();
const fileParts = ["Hello Jira!"];
const blob = new Blob(fileParts, {type : 'text/plain'});

formData.append('image', blob, 'file_name.txt' );

await fetch('{ID}/attachment', {
method: 'POST',
headers: {
'Authorization' : 'Basic BASE64',
'Content-Type': 'multipart/form-data',
'X-Atlassian-Token': 'no-check'
data: formData


1 answer

1 accepted

3 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 03, 2019

Hi Jarrod,

Service Desk Cloud does this a bit differently than Jira Core or Jira Software would.  This is because Service Desk has some default restrictions as to what the customer can see via the customer portal.  The endpoint you're trying to POST to is documented in

From that page:

POST /rest/servicedeskapi/request/{issueIdOrKey}/attachment

This method adds one or more temporary files (attached to the request's service desk using servicedesk/{serviceDeskId}/attachTemporaryFile) as attachments to a customer request and set the attachment visibility using the public flag. Also, it is possible to include a comment with the attachments.

To get a list of attachments for a comment on the request use servicedeskapi/request/{issueIdOrKey}/comment/{commentId}/attachment.

So in this case, this endpoint can only add a temporary file that has already been uploaded to this issue.  That endpoint is not where you actually upload the file itself via REST. 

Instead you should first use the POST /rest/servicedeskapi/servicedesk/{serviceDeskId}/attachTemporaryFilePOST endpoint to upload that file.   Once that temp file is there, you need to find the Id of that file (which you will see in the response if uploaded successfully, OR you could call the endpoint GET /rest/servicedeskapi/request/{issueIdOrKey}/attachment to see all temp files on that issue).  From there you can use your other endpoint to post this attachment, choose public as true if the customer is supposed to see this attachment, and add a comment if you like.

The syntax for that in curl would look like this:

curl --request POST \
  --url '{issueIdOrKey}/attachment' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "temporaryAttachmentIds": [
  "public": true,
  "additionalComment": {
    "body": "Please find the screenshot and the log file attached."

I hope this helps.


Andy, this is very helpful and we have it already working!  Thanks so much!

hey i am getting "" this error - i do get tempid but while uploading attachments it throws this error and if i copy the temp id and upload it through postman it works fine.Strange isn't it

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 30, 2020

That is very strange to see.  I have not found any other occurrences of this particular error having been reported in any of our support channels.  @raveena I would be interested to learn more about the details of your REST call here.  Such as

  1. How large the file is you are uploading?
  2. What specific headers being sent with your rest call?
  3. How long between the time this request is sent and the time you see this error?  The timeout aspect makes it seem like perhaps the request cannot be completed within defined time period.
  4. You mentioned this working in Postman, what kind of REST client are you using where this is not working? Curl, a connect app, some other rest client?

I am interested to try to learn more here, however we might want to create a new question to address that specific problem.


Hey Andy,

I'm looking through the documentation on the Service Desk API page and I'm a little confused. When attaching a temporary file onto the service desk there is no example that shows how to actually give a file path. There is a command line example that includes a file path, but nothing for in app use. Am I missing something?



Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jul 15, 2020

Hi Alistair,

I'm not sure I have a clear answer for that.  I have not built a connect app to perform this action, so it's not clear to me how it might be different.  But perhaps one of the coded solutions on this other thread might help shed some light on it

There are a few different examples there, but granted these are using the Jira Core REST APIs to upload files to Issues.  It's not exactly the same as Service Desk adding such files to requests, but it's very close in nature that perhaps these example might help.

Hi Andy,

Thanks for your answers on this topic.
Most of the time, we get the following errors  when we use attachTemporaryFile before attachment :

{‘errorMessage’: ‘An error occurred while processing the attachment. Could not save attachment to storage: Source file does not exist /var/atlassian/jirahomelocal/caches/tmp_attachments/temp1076873519188975551’, ‘i18nErrorMessage’: {‘i18nKey’: ‘sd.attachment.create.error’, ‘parameters’: [‘Could not save attachment to storage: Source file does not exist /var/atlassian/jirahomelocal/caches/tmp_attachments/temp1076873519188975551’]}}

{‘errorMessage’: ‘There was a problem saving the attachments for this comment’, ‘i18nErrorMessage’: {‘i18nKey’: ‘sd.attachment.temporary.session.time.out.ids’, ‘parameters’: []}}

A lot of them disappear if we add a sleep between attachTemporaryFile and attachment but that's an arbitrary solution so that is not very clean.

Is there a way to ensure that the temporary file has been properly uploaded before to call /rest/servicedeskapi/request/{issueIdOrKey}/attachment ?

Katherine Regan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jun 09, 2021

Hey @Aymeric Hermant , about how long is your sleep (if you know)? Also, do you know what request status you're getting on the first error call? 400 or 500?

We're also seeing this issue. Most of the time the attachment call works, but sometimes the temporary attachment ids give the message error message you posted.


I am also getting this error on JSM Sandbox,  but the same code works fine on regular JSM,

Suggest an answer

Log in or Sign up to answer