question

Ward avatar image
Ward asked beckham86 answered

Json payload succeeds to checkouts endpoint, fails to orders

I can't figure out what I am doing wrong. Using atomic_order/checkouts, my json payload succeeds, but the same payload fails at the /orders endpoint. I am using RestSharp:

var rootSerial = JsonConvert.SerializeObject(myOrderCartObject);
request.AddStringBody(rootSerial, ContentType.Json);

Payload:

{"orderCart":{"discounts":null,"lineItems":{"elements":[{"item":{"id":"3282V1W6NKDRY"},"alternateName":null,"discounts":null,"exchanged":false,"modifications":{"elements":[{"item":null,"alternateName":null,"discounts":null,"exchanged":false,"modifications":null,"modifier":{"id":"HWXM6GTYF1CGG"},"id":null,"name":null,"modifierIds":null,"modifierGroup":null}]},"modifier":null,"id":null,"name":null,"modifierIds":null,"modifierGroup":null}]}},"name":null,"price":0,"modifierGroups":null,"elements":null,"href":null}

Grateful for any help. Thanks.


Orders
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bryanvargas avatar image bryanvargas ♦♦ commented ·
I used your same code and did not run into any problems. I would suggest double-checking your code or seeing what the exact error message is.
1 Like 1 ·

1 Answer

·
beckham86 avatar image
beckham86 answered
  1. Payload Structure: Ensure that the structure of your JSON payload matches the expected format for the /orders endpoint. While the payload may work for /checkouts, the /orders endpoint might require additional fields or a different structure. Check the API documentation for any specific requirements for the /orders endpoint.
  2. Required Fields: The /orders endpoint may have mandatory fields that are not included in your current payload. For example, fields like customer, shippingAddress, or billingAddress might be required. Make sure to include all necessary information.
  3. Data Types: Verify that the data types of the values in your JSON payload are correct. For instance, if a field expects a string but receives a number, it could lead to a failure.
  4. Error Messages: If the API returns an error message when the request fails, examine it closely. The error message can provide clues about what might be wrong with the payload.
  5. Testing with Minimal Payload: Try sending a minimal version of your payload that includes only the essential fields required by the /orders endpoint. This can help Doodle Jump isolate the issue and determine if a specific part of your payload is causing the failure.
  6. API Versioning: Ensure that you are using the correct version of the API that corresponds to the documentation you are referencing. Sometimes, changes in API versions can lead to differences in expected payloads.
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community