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?
The "multipart/form-data" is probably added automatically because
type="file"
is used. If the API is expecting content type "application/octet-stream", that suggests it expects file data to be uploaded through the http request body, rather than as a named "file" field. Instead oftype="file"
try using: