这是我的代码。我正在尝试从 android (API 10) 发布关于其余 Api 的帖子
HttpPost httpPost = new HttpPost(
"http://www.reactomews.oicr.on.ca:8080/ReactomeRESTfulAPI/RESTfulWS/queryHitPathways");
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Content-Type"," text/plain; charset=UTF-8");
httpPost.addHeader("","PPP2R1A,CEP192,AKAP9,CENPJ,CEP290,DYNC1H1");
try {
HttpResponse response = client.execute(httpPost);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
} else {
System.out.println(statusCode);
Log.e(Gsearch.class.toString(), "Failed to download file");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return builder.toString();
}
我只是不知道在最后一个 addHeader 方法中添加什么(作为第一个字符串)!我尝试了“名称”、“ID”等。它也没有在 API 中列出。API 文档在这里:http://reactomews.oicr.on.ca:8080/ReactomeRESTfulAPI/ReactomeRESTFulAPI.html 我尝试使用 firebug 在浏览器中查看发布请求,但它显示 post data = "PPP2R1A,CEP192,AKAP9, CENPJ、CEP290、DYNC1H1" .
现在我在那里使用“body”,我得到一个长度为 0 的 json 响应。但是,如果我从文档链接尝试浏览器,我会得到一个 json 响应。所以错误在 addHeader 部分。