I am attempting to upload a file to the dropbox api using cfhttp. I am getting an error from Dropbox stating the Content-Type is incorrect:
Bad HTTP "Content-Type" header: "application/octet-stream,multipart/form-data; boundary=-----------------------------7d0d117230764". Expecting one of "application/octet-stream", "text/plain; charset=dropbox-cors-hack".
It appears to me that ColdFusion is appending multipart.form-data to the content type I defined in the cfhttpparam header. I am not sure how to prevent this. I am using the code below:
<cfhttp method="post" url="https://content.dropboxapi.com/2/files/upload" result="uploadFile" multipart="no">
<cfhttpparam type="header" name="Authorization" value="Bearer #DropboxAccessToken#">
<cfhttpparam type="header" name="Dropbox-API-Arg" value="#serializeJSON(stFields)#">
<cfhttpparam type="header" name="Dropbox-API-Select-User" value="#DropboxMemberID#">
<cfhttpparam type="header" name="Content-Type" value="application/octet-stream">
<cfhttpparam type="file" name="1_1036.gif" file="C:\1_1036.gif">
</cfhttp>
Any ideas on what could be going on?
type="file"
is used. Try sending the file binary as the request body instead, i.e.<cfhttpparam type="body" value="#FileReadBinary('C:\1_1036.gif')#">
– Leigh