I am calling the amadeus self-service APIs without the JAVA SDK from a Spring Boot application. In the first call I am getting the access_token successfully by calling the authorization API. Now with that access_token if I call the Airport & City Search, I am getting this response.
{
"errors": [
{
"code": 38197,
"title": "Forbidden",
"detail": "Access forbidden",
"status": 403
}
]
}
I am passing the access_token as a bearer token in the request header. Below is my code.
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;
}
The same token is working fine with the Postman.
Am I missing something here?
Thanks in advance.
You are using http
instead of https
for the url.