Towsif Ahamed Labib
Towsif Ahamed Labib

Reputation: 716

Error 400 When Trying to Deny Uber Eats Order Using API: "Could not parse json"

I'm integrating Uber Eats order denial functionality into our system and followed the official documentation for denying an order. However, I'm encountering a 400 Bad Request error with the message that JSON could not be parsed. I ensured that my request adheres to the documentation's specifications, including providing a valid deny_reason object.

Here is the request body I'm sending:

{
  "deny_reason": {
    "info": "Item is not available",
    "type": "ITEM_ISSUE",
    "client_error_code": 408,
    "item_metadata": {
      "invalid_item": [
        {
          "id": "2022",
          "type": "NOT_ON_MENU",
          "client_error_code": 408,
          "info": "Broken oven.",
          "external_id": "chz_piz_18"
        }
      ]
    }
  }
}

The error message I received is "Error: 400. Could not parse json":

{"error":"Could not parse json: merchant_orders_presentation.DenyOrderRequest.DenyReason: merchant_orders_presentation.RejectionReason.ClientErrorCode: ReadString: expects \" or n, but found 4, error found in #10 byte of ...|or_code\":408,\"item_m|..., bigger context ...|available\",\"type\":\"ITEM_ISSUE\",\"client_error_code\":408,\"item_metadata\":{\"invalid_item\":[{\"id\":\"2022\",\"|...}"}

I've followed the documentation provided at https://developer.uber.com/docs/eats/references/api/order_suite#tag/DenyOrder closely, but I'm unsure why I'm encountering this parsing error. The client_error_code is specified as an integer, and my JSON structure matches the examples given.

Has anyone encountered this issue before or can spot what I might be doing wrong? Any guidance or suggestions would be greatly appreciated.

Upvotes: 0

Views: 172

Answers (1)

Towsif Ahamed Labib
Towsif Ahamed Labib

Reputation: 716

The issue seems to stem from a discrepancy in the Uber Eats API documentation. Despite the documentation suggesting that client_error_code should be an integer, submitting it as a string ("408") instead of an integer (408) resolves the error.

"client_error_code": "408",

Changing the client_error_code to a string in the request body allows the API to process the request successfully. This indicates that the API expects client_error_code as a string, contrary to the documentation.

Upvotes: 0

Related Questions