http://onemoredemo.appspot.com/group?authToken=access_token&authMethod=oauth
请求体包含json对象,如下所示.
{"goupid":"some_variable" }
URL url1=new URL("http://onemoredemo.appspot.com/group?authToken="+access_token+"&authMethod=oauth"); conn=(HttpURLConnection) url1.openConnection(); conn.addRequestProperty("Content-type","application/x-www-form-urlencoded"); conn.setRequestMethod("GET"); conn.setDoOutput(true); JSONObject jj=new JSONObject(); HttpGet get; get. jj.put("groupid","testing@iritesh.com"); conn.addRequestProperty("Content-TYpe","application/json"); conn.getOutputStream().write(jj.toString().getBytes()); conn.connect(); InputStream is=conn.getInputStream();
我收到一个错误java.io.FileNotFoundException.
我从mozilla浏览器发送了一个请求到url
http://onemoredemo.appspot.com/group?authToken=ya29.AHES6ZRDl-RqiA8W0PhybU_hMluHrHRjlJBvq06Vze0izJq0Ovjc088&authMethod=oauth
它正在给我正确的答复,但现在它超过一个小时,所以acccesstoken到期.我知道它有奇怪的发送参数以及请求的请求,但我必须发送它.
请帮助如何在请求体中发送json对象以获取请求.
解决方法
读这个:
http://tech.groups.yahoo.com/group/rest-discuss/message/9962
“Yes. In other words,any HTTP request message is allowed to contain a
message body,and thus must parse messages with that in mind. Server
semantics for GET,however,are restricted such that a body,if any,
has no semantic meaning to the request. The requirements on parsing
are separate from the requirements on method semantics.So,yes,you can send a body with GET,and no,it is never useful to
do so.This is part of the layered design of HTTP/1.1 that will become clear
again once the spec is partitioned (work in progress).”
关于这个检查的其他有趣的讨论:
https://stackoverflow.com/a/978094/550967