Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unwanted exception on Delete Flight Order Management API #95

Closed
tsolakoua opened this issue Jan 14, 2021 · 0 comments · Fixed by #96
Closed

Fix unwanted exception on Delete Flight Order Management API #95

tsolakoua opened this issue Jan 14, 2021 · 0 comments · Fixed by #96
Assignees
Labels
bug Something isn't working

Comments

@tsolakoua
Copy link
Member

The Flight Orders Management API returns en empty body with status code 204 when an order is deleted successfully. The SDK doesn't handle this use case properly; it throws a ParserException as the API does not return a FlightOrder object, instead returns the empty response with code 204.

How to reproduce

import com.amadeus.Amadeus;
import com.amadeus.booking.FlightOrder;
import com.amadeus.exceptions.ResponseException;

public class FlightOrderManagement {
    public static void main(String[] args)  throws ResponseException {
      Amadeus amadeus = Amadeus
              .builder("client_key","client_secret")
              .build();
      com.amadeus.resources.FlightOrder order = amadeus.booking.flightOrder("eJzTd9cP8A8y8nIDAAtUAlk").delete();

      if (order.getResponse().getStatusCode() != 204) {
        System.out.println("Wrong status code: " + order.getResponse().getStatusCode());
        System.exit(-1);
      }

      System.out.println("deleted");
     }
}
Exception in thread "main" com.amadeus.exceptions.ParserException: [204]
        at com.amadeus.Response.detectError(Response.java:79)
        at com.amadeus.HTTPClient.execute(HTTPClient.java:361)
        at com.amadeus.HTTPClient.unauthenticatedRequest(HTTPClient.java:253)
        at com.amadeus.HTTPClient.request(HTTPClient.java:339)
        at com.amadeus.HTTPClient.delete(HTTPClient.java:94)
        at com.amadeus.booking.FlightOrder.delete(FlightOrder.java:85)
        at com.amadeus.booking.FlightOrder.delete(FlightOrder.java:95)
        at flightsearch.FlightSearch.main(FlightSearch.java:17)
@tsolakoua tsolakoua self-assigned this Jan 14, 2021
@tsolakoua tsolakoua added the bug Something isn't working label Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant