Closed MQ9Realper closed 6 years ago
I tried your code and it works on my side.
Are you sure about your implementation of the Constants class and the API Key / API Secret you used?
Are you sure about the dependencies you use: you need to import the SDK library version 1.1.0 and the gson library:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amadeus/amadeus-java -->
<dependency>
<groupId>com.amadeus</groupId>
<artifactId>amadeus-java</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
Attempt to invoke virtual method 'java.lang.String com.google.gson.JsonElement.getAsString()' on a null object reference
The above error occurs when I call the Locations endpoint via this library. Below is the complete stacktrace:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.gson.JsonElement.getAsString()' on a null object reference at com.amadeus.Response.detectError(Response.java:69) at com.amadeus.HTTPClient.execute(HTTPClient.java:223) at com.amadeus.HTTPClient.unauthenticatedRequest(HTTPClient.java:117) at com.amadeus.HTTPClient.request(HTTPClient.java:202) at com.amadeus.HTTPClient.get(HTTPClient.java:66) at com.amadeus.referenceData.Locations.get(Locations.java:67)
Below, is how I am implementing the call:
**//Initialize using parameters new Thread(new Runnable() { @Override public void run() { Amadeus amadeus = Amadeus .builder(Constants.AMADEUS_CLIENT_ID, Constants.AMADEUS_SECRET_KEY) .build();