I am unable to upload a file with the file API
I've tried this HTTP request in POSTMAN and Curl with no success and the same result on both: Attach a file (picture) to a conversation
Would you be able to share a real working example from Postman, or from Postman convert to a Curl code snippet that I can import?
The following returns "wrong Content-Disposition header was set"
POST /rest/v2/fileapi HTTP/1.1
Host: circuitsandbox.net
Authorization: Bearer MyTokenCodeGoesHere
Content-Length: 100
Content-Disposition: attachment; filename="test.txt"
Cache-Control: no-cache
MyBinaryCodeGoesHere
The above looks like this in curl:
curl --location --request POST "https://circuitsandbox.net/rest/v2/fileapi" \
--header "Authorization: Bearer MyTokenCodeGoesHere" \
--header "Content-Length: 100" \
--header "Content-Disposition: attachment; filename=\"test.txt\"" \
--header "Cache-Control: no-cache" \
--header "MyBinaryCodeGoesHere: "
Tested with Host: local.circuit.com
instead of Host: circuitsandbox.net
, no connection, I assumed it was just an example, but mentioning just in case.
Expected:
{"fileId":"fb211fd6-df53-4b82-824d-986dac47b3e7","attachmentId":"ZmIyMT..."}
Actual result:
"wrong Content-Disposition header was set"
Here is a curl example posting a json document:
curl -X POST https://circuitsandbox.net/rest/v2/fileapi \
-H 'authorization: Bearer <token>' \
-H 'cache-control: no-cache' \
-H 'content-disposition: attachment; filename="test.json"' \
-H "Content-Type: application/json" \
-d '{"key":"val"}'
Using postman you can easily set a file to upload in the body's binary tab. The only headers you'll need are "Authorization" and "Content-Disposition". The "Content-Disposition" header has the format: attachment; filename="test.log"
In your example the data does not look right. It should not be passed in a header.