Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Content-length 0 when using JIRA CURL command to upload a attachment

Bhavya K
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 5, 2023

We are trying to upload an attachement in the issue using curl command. The http resopnse code is 200 but content length is 0 and attachment is not uploading.

Command:

curl -D- -u admin:admin -X POST -k -H "X-Atlassian-Token: no-check" -F "file=@myfile.txt" http://myhost/rest/api/2/issue/TEST-123/attachments
Response:
Image_20230905_213457_054.jpg
Any help will be appreciated

1 answer

0 votes
Jehan Bhathena
Community Champion
December 30, 2023

Hi @Bhavya K ,

I haven't tested this on the Server API, but for Cloud I use a similar API I would suggest adding the complete path of the attachment instead of just the name eg. (also note the use of Single quote for hardcoded text)

curl -D- -u admin:admin -X POST -k -H "X-Atlassian-Token: no-check" -F 'file=@'"./tmp/path/myfile.txt" http://myhost/rest/api/2/issue/TEST-123/attachments

Do let me know if this helps, also, please mark this thread as Accepted if this solves your query.

Suggest an answer

Log in or Sign up to answer