【发布时间】:2017-05-04 06:02:02
【问题描述】:
我正在尝试对 sabre 的 api 进行 GET 调用。我没有收到 我的回复中的数据,我对 httpGet/post/request 还很陌生。
public HttpResponse callGetMethod() {
HttpResponse response = null;
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI("https://api.sabre.com/v1/shop/flights?origin=ATL&destination=LAS&departuredate=2016-08-13&returndate=2016-08-15&limit=1&enabletagging=true"));
response = client.execute(request);
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return response;
}
我觉得我只是在某个地方错过了一小步。
感谢任何帮助!
【问题讨论】:
-
“但我似乎无法得到我想要的东西”:如果你告诉我们你想要什么,我们可能会提供帮助。什么没有按预期工作?
-
确保在 Manifest 文件中添加 Internet 权限。这是新手常犯的错误
-
另外,如果您可以详细说明错误或异常,或者可以粘贴您的日志,那么我们可以提供进一步的帮助
-
我的回复中没有收到任何数据。我正在使用异步任务,但这只是内部调用的方法。
-
如果有帮助,GET 格式应如下所示:
标签: android rest api http-get sabre