A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi,
I need to make an API call to return all the gift cards associated with a customer id.
I can successfully make an API call based on the last characters of a gift card. The below call returns a collection with one gift card object, as expected.
const API_URL = ‘…myshopify.com/admin/api/2022-01/gift_cards/search.json?query=last_characters:kh3x'
However, I need a collection with all gift card objects associated with the customer_id. The following call attempts to query by the customer_id that was returned by the above call. It does not return any gift cards:
const API_URL = ‘…myshopify.com/admin/api/2022-01/gift_cards/search.json?query=customer_id:5382638226'
The call is successful in that it returns an object, but the object contains no gift cards: {gift_cards=[]}
I understand that the gift cards don’t “belong” to the customer object, but the customer_id is a property of the gift card object, just as last_characters is a property of the gift card object, do I don’t understand why the first call works and the second doesn’t. I’ve tested it with several customer id numbers, with the same result.
Help, please?
Hey @LSchroeder,
The gift card search endpoint does not support search by customer_id. you should use email field instead like below:
const API_URL = ‘…myshopify.com/admin/api/2022-01/gift_cards/search.json?query=email:customer@example.com'