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

ProductPricingV0: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY #355

Open
dfreudenberger opened this issue Mar 19, 2024 · 0 comments

Comments

@dfreudenberger
Copy link

dfreudenberger commented Mar 19, 2024

I'm working with Amazon's SP-API SDK to pull item offers using the Product Pricing V0 API.

However, when I make a batch request and any of the batched requests returns an error, the getItemOffersBatch method throws an IllegalStateException. Ideally, I'd like the request to go through, and for the response list to include a GetOffersResponse object filled with any errors that happened.

Please find attached one of the responses that will lead to the mentioned exception.

{
  "responses": [
    {
      "headers": {
        "x-amzn-RequestId": "f53e7f5f-61b8-4a2b-8d2e-028809d6eb84",
        "Date": "Tue, 19 Mar 2024 17:02:02 GMT"
      },
      "status": {
        "statusCode": 400,
        "reasonPhrase": "Bad Request"
      },
      "body": {
        "errors": [
          {
            "message": "B00ZUXG6GY is an invalid ASIN for marketplace A1PA6795UKMFR9",
            "details": "",
            "code": "InvalidInput"
          }
        ]
      },
      "request": {
        "MarketplaceId": "A1PA6795UKMFR9",
        "ItemCondition": "Used",
        "Asin": "B00ZUXG6GY"
      }
    }
  ]
}

Swagger codegen generates the following classes (stripped down to what is important) from the v0 model.

public class GetOffersResponse {
  @SerializedName("payload")
  private GetOffersResult payload = null;

  @SerializedName("errors")
  private ErrorList errors = null;
}

public class ErrorList {
  @SerializedName("errors")
  private List<Error> errors = new ArrayList<>();
}

public class Error {
  @SerializedName("code")
  private String code = null;

  @SerializedName("message")
  private String message = null;

  @SerializedName("details")
  private String details = null;
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant