我正在从Spring Boot应用程序中调用没有JAVA SDK的amadeus自助服务API。在第一个调用中,我通过调用授权API成功获得了access_token。现在,如果我致电Airport&City Search,则使用该access_token,将收到此响应。
{
"errors": [
{
"code": 38197,
"title": "Forbidden",
"detail": "Access forbidden",
"status": 403
}
]
}
我正在将access_token作为承载令牌传递到请求标头中。下面是我的代码。
public String getCityList(String keyword) throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(authToken);
HttpEntity<String> entity = new HttpEntity<String>(headers);
String url = "http://test.api.amadeus.com/v1/reference-data/locations?subType=AIRPORT,CITY&keyword=" + keyword
+ "&page[limit]=5";
String body = restTemplate.exchange(url, HttpMethod.GET, entity, String.class).getBody();
return body;
}
同一个标记与邮递员配合良好。
我在这里想念东西吗?
提前感谢。
您正在使用http
代替URL的https
。