2011-10-11 56 views
0

我的代码是:401擅自城市飞艇错误的Android

String encodedData = Base64.encodeBytes("YxxxxxxxxxxxxxxxA".getBytes()); 

HttpParams httpParams = new BasicHttpParams(); 
       HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC); 
       HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC); 
       HttpClient client = new DefaultHttpClient(httpParams); 

       HttpPost request = new HttpPost("https://go.urbanairship.com/api/airmail/send/broadcast/"); 
       //request.setHeader(header) 
       request.addHeader("Authorization", "Basic " + encodedData) 

正在使用的应用程序的主秘密按照该文件建议在这里:

http://urbanairship.com/docs/richpush.html?highlight=broadcast

但我得到401未经授权错误。

如何解决这个问题?

谢谢

回答

1

401错误表示您没有正确验证。看到这个:http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error

你确定你正在提供你的凭据吗?

+0

是的主秘密是通过,我检查它的正确,但是这种身份验证的方式.. – Udaykiran

+0

呃,这是2016年,我现在有这个问题。没有人似乎有答案:http://stackoverflow.com/questions/35664399/how-come-i-keep-getting-a-request-failed-with-response-code-401-when-trying-to – Silverstar