I am trying a simple request to test the TripAdvisor API :
public static void main(String[] args) {
try {
HttpRequest request = HttpRequest
.newBuilder()
.uri(URI
.create("https://api.content.tripadvisor.com/api/v1/location/search?key=" + TRIPADVISOR_API_KEY + "&searchQuery=" + QUERY
+ "&language=fr"))
.header("accept", "application/json")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
and TripAdvisor returns me the following response :
{
"error": {
"message": "invalid client key: <TRIPADVISOR_API_KEY>-mapper",
"type": "UnauthorizedException",
"code": "160"
}
}
<TRIPADVISOR_API_KEY> is obviously the provided key.
I do not understand what is this '-mapper' suffix added to the key.
Do anybody have encounter the same problem or can give me some clues about what happens?
I tries a similar code with Jsoup or HttpUrlConnection, i have the same problem every time.
After one day, the problem disappears. The error message was misleading, and the documentation was unclear, as they say to wait for 15 minutes after the creation.