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

Confluence file attachment issue using the REST API

Phani Oct 20, 2015

This is the error response i get..

"{ statusCode: 400 message: "At least one attachment file must be included." }".

I know the HTTP POST message is well formatted as a multipart/form-data, any suggestions what might be missing

3 answers

0 votes
Jesper Balle Mar 08, 2016

 

I have the same issue, did you solve it?

My request is looking like this (with the actual values in the <tokens>

POST https://&lt;mywiki&gt;.atlassian.net/wiki/rest/api/content/&lt;pageid&gt;/child/attachment HTTP/1.1
X-Atlassian-Token: nocheck
Accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml
User-Agent: RestSharp/105.2.3.0
Content-Type: multipart/form-data; boundary=-----------------------------28947758029299
Host: &lt;mywiki&gt;.atlassian.net
Cookie: studio.crowd.tokenkey=&lt;myvalue&gt;
Content-Length: 40797
Accept-Encoding: gzip, deflate
-------------------------------28947758029299
Content-Disposition: form-data; name="&lt;filename&gt;.png"; filename="&lt;filename&gt;.png"
Content-Type: application/octet-stream
 PNG
&lt;Removed for readability&gt;
-------------------------------28947758029299--

 

Thank you

 

0 votes
Giang Đỗ Mar 09, 2016

I got this error, too when used Application Link on JIRA 7, did you resolve it?

0 votes
Jesper Balle Mar 09, 2016

Well yes, I dowloaded curl, tried the examples from the documentation and compared the requests in Fiddler. The main difference was actually that  the Content-Disposition name in the multipart must be "File". Apart from that I actually ended up building the multi part my self

So the request that worked for me became:

POST https://&lt;mywiki&gt;.atlassian.net/wiki/rest/api/content/&lt;pageid&gt;/child/attachment HTTP/1.1
X-Atlassian-Token: nocheck
Accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml
Content-Type: multipart/form-data; boundary=-----------------------------28947758029299
Host: &lt;mywiki&gt;.atlassian.net
Cookie: studio.crowd.tokenkey=&lt;myvalue&gt;
Content-Length: 40797
Accept-Encoding: gzip, deflate

-------------------------------28947758029299
Content-Disposition: form-data; name="File"; filename="&lt;filename&gt;.png"
Content-Type: application/octet-stream

 PNG
&lt;Removed for readability&gt;
-------------------------------28947758029299--

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

6 Awesome Ways to Apply Trello, JIRA and Confluence to your Project

I attended  Atlassian Summit 2019  and learned a lot from the presenters, attendees and knowledgeable Atlassian product managers. The presentations I attended focused on applying Agile, pla...

1,125 views 7 18
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