我的代码是:
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个未经授权的错误。
如何解决这个问题?
由于
答案 0 :(得分:1)
401错误表示您未经过正确的身份验证。请参阅:http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error
您确定要正确提供凭据吗?