AS3: Sending empty Content-Type header in urlrequestHeader

断了今生、忘了曾经 提交于 2019-12-12 05:52:45

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/43448733/as3-sending-empty-content-type-header-in-urlrequestheader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!