Discussing APIs and development related to customers, discounts, and order management.
I'm trying to get all orders but only need a few fields. So I decided to use the fields parameter in the API to get the required fields for my needs. Now I ran into a problem that the email field is populated on one order and not the other. When adding/removing a field, the orders that have email then return null and others that were null return email.
The fields I need are "email,customer,line items,billing address,shipping address,shipping rules,discount codes,current_total_discounts_set,current_total_discounts,created_at"
When I enter that in the fields parameter, I get the following results:
For example, when I remove the "created_at" field, the results change to:
The endpoint I'm using is: "/admin/api/2022-07/orders.json?status=any&fields={fields}".
What am I doing wrong?
Hey @ADJUST-IT - thanks for getting in touch, this is definitely odd. I was able to test an API call on my development store using the endpoint and fields you provided and wasn't able to replicate the issue. The fields and values showed up as expected for me.
That said, if you could share an X-Request-ID from one of the response headers you received when the issue occurs on your end, I can use that to track down the specific API call in our logs and see if we can find out what may be happening here.
Happy to dig into this further - hope to hear from you soon.
Alan | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hey @Alan, thanks for the reply.
I have 2 new request where I saved the X-Request-ID from.
The first request is done with asking the following fields "email,customer"
The X-Request-ID from that request is "3ae8909a-88f5-4a44-836c-80a3c280ac96"
That request seems to do the job. However as mentioned I need more data than that.
So for the other request I requested the fields I need "email,customer,line_items,billing_address,shipping_address,shipping_lines,discount_codes,current_total_discounts_set,current_total_discounts,created_at,id,order_number".
The X-Request-ID from that request is "025edb03-d3a0-4fd2-a97a-800f6d3b6ac0".
With that request it gives no email data in return.
I olso tested it on multiple platform with all the same data.
I used a C# test code, Insomina REST and Node.js test code.
In the attachments I includet a test snippet that can be run by Node, Deno or Bun.
Only the shopname and the token need to be filled in at the top of the file.