简体   繁体   English

在Android中通过Imgur的API上传图像时,“权限被拒绝”

[英]“Permission denied” when uploading an image through Imgur's API in Android

I am trying to upload an image in Android. 我正在尝试在Android中上传图片。 The documentation for the header can be found here: https://api.imgur.com/#authentication . 标题的文档可以在以下位置找到: https : //api.imgur.com/#authentication

I am using the following line of code to authorize my app: 我正在使用以下代码行来授权我的应用程序:

httpPost.setHeader("Authorization:", "Client-ID " + Constants.MY_IMGUR_CLIENT_ID);

I keep getting the response: 我不断得到回应:

org.apache.http.client.HttpResponseException: Permission Denied

Is the header wrong or do I need to look elsewhere in my code to find the error? 标头是否错误,还是需要在代码中其他地方查找错误?

Did you try 你试过了吗

httpPost.setHeader("Authorization", "Client-ID " + Constants.MY_IMGUR_CLIENT_ID); httpPost.setHeader(“ Authorization”,“ Client-ID” + Constants.MY_IMGUR_CLIENT_ID);

(without colon)? (没有冒号)?

The following has worked for me before: 以下对我有用:

httpPost.setHeader("Authorization", "Client-ID " + Constants.MY_IMGUR_CLIENT_ID);

Notice the missing colon 注意缺少的冒号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM