我正在创建一个连接到Web服务并获取响应代码的Android客户端。问题是Android应用程序崩溃,每当我运行下面的代码:在休息框架中获取请求错误
RequestParams params = new BasicRequestParams();
params.add("client_id", "24f8b46fc9db409012830ca264ad7bcf");
params.add("response_type", "code");
ServiceResponse response=Resting.get("http://pricewatch.ap01.aws.af.cm/api/pricewatch/oAuth/auth",80,params);
IContentData contentData = response.getContentData();
String content = (String) contentData.getContent();
JSONObject jsonObject = new JSONObject(content);
String code = (String) jsonObject.get("code");
return code;
它产生与这些线显示java.lang.NullPointerException:
IContentData contentData = response.getContentData();
可能有人用这些帮助吗?我一直坚持这些。提前致谢!
您是否检查过'reponse' var的值? – 2013-05-10 18:29:09
另外我试图在restlet框架中实现它相同的响应。我转向休息框架。您看到的代码在休息框架中实现 – Carmad94 2013-05-11 01:07:17
我在java应用程序中运行此代码。它工作并且响应var返回一个json格式和响应头文件。 – Carmad94 2013-05-11 03:12:38