我试图在box.com上传文本文件。我正在使用Android异步Http客户端。我更喜欢使用它,因为它更干净。 Box.com文件上传说明:http://developers.box.com/docs/#files-upload-a-file。
我试过并且总是得到访问令牌未找到错误。我不想使用android box.com sdk。
File myFile = new File(path_to_file + "test.txt"));
RequestParams params = new RequestParams();
params.put("filename", "test.txt");
params.put("parent_id", "0");
AsyncHttpClient client = new AsyncHttpClient();
client.addHeader("Authorization", "Bearer " + "TOKEN");
client.post("https://upload.box.com/api/2.0/files/content", params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
System.out.println(response);
}
});
Authentication error: Unable to respond to any of these challenges: {bearer=WWW- Authenticate: Bearer realm="Service", error="invalid_request", error_description="The access token was not found."}
答案 0 :(得分:0)
我设法通过删除我包含的Content-MD5标题解决了这个问题(我上面忘了提到它)。不知何故,标题中的值设置不正确。