简体   繁体   中英

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

I am trying to upload an image in Android. The documentation for the header can be found here: 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);

(without colon)?

The following has worked for me before:

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

Notice the missing colon

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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