0

I want to download file from dropbox api. Below is the snippet of my code.

        var oauthHeader:URLRequestHeader = OAuthHelper.buildRequestHeaderWithToken(config.accessTokenKey);
        var urlRequest:URLRequest = new URLRequest();
        var jsonPath:String = JSON.stringify(params);
        var requestHeader:URLRequestHeader = new URLRequestHeader("Dropbox-API-Arg",jsonPath);

        urlRequest.requestHeaders = [oauthHeader,requestHeader];
        urlRequest.contentType = "";
        urlRequest.method = httpMethod;
        urlRequest.url = url;

I get the following error when making request.

Error in call to API function "files/download": You provided a non-empty HTTP "Content-Type" header ("application/x-www-form-urlencoded"). This API function requires that the header be missing or empty.

How can I send empty 'Content-Type' header.

  • Did you try **new URLRequestHeader("Content-Type", "");**? Did you try searching for existing solution (this one looks like DropBox client: https://github.com/grossopa/dropbox-as3)? – Organis Apr 17 '17 at 11:09
  • The library you mentioned is out-dated, dropbox has upgraded their api so this library can't be used. I tried your solution and it doesn't work. – muhammad adil Apr 19 '17 at 09:03

1 Answers1

0

I found the way. The correct way to send the empty content-type header is to put a space in a value.

new URLRequestHeader("Content-Type", " ");

if you don't put a space and send empty string it will give you the error.