80,351
社区成员
发帖
与我相关
我的任务
分享
public JSONObject shopCarByput(String token, int id)
throws ParseException, IOException, JSONException {
String shopPut = shopcar_get + "/" + id;
Log.e("URL", shopPut);
HttpClient httpClient = new DefaultHttpClient();
HttpPut request = new HttpPut(shopPut);
request.addHeader("Authorization", "bearer " + token);
request.addHeader("Content-Type", "application/x-www-form-urlencoded");
HttpResponse httpResponse = httpClient.execute(request);
int code = httpResponse.getStatusLine().getStatusCode();
HttpEntity httpEntity = httpResponse.getEntity();
Logs.e("code-------------"+code);
String result2 = (httpEntity == null) ? null : (EntityUtils
.toString(httpEntity, "UTF-8"));
JSONObject result1 = JSONObject.fromObject(result2);
return result1;
}
我觉得request.addHeader("Authorization", "bearer " + token);,为什么token验证前面,你还加个“bearer” 这个是不是可以说你后台没有验证成功,需要同后台协商解决这个身份验证的问题 朋友,错误代码401是因为身份验证问题。你的身份验证应该错了,不是这里的
request.addHeader("Authorization", "bearer " + token); request.addHeader("Content-Type", "application/x-www-form-urlencoded");这里不是已经传入了么
传入的值有问题,没有和服务格式对应
朋友,错误代码401是因为身份验证问题。你的身份验证应该错了,不是这里的