Query Gift Card API for updated after

Solved
Shopify Partner
6 0 0

Our stores have enabled the API access for gift cards.  Authorized the app and Account manager has approved access.  I am able to successfully query the gift_cards API to see all gift cards.

 

We would like to get a list of gift cards that have been updated since a particular date.  Similar to how we would query the orders with updated_at_min.  I apologize, as it is not clear to me when reading the gift card API docs.

 

gift_cards.json

https://help.shopify.com/en/api/reference/plus/giftcard#index -- doesn't have a date filter

gift_cards/search.json
https://help.shopify.com/en/api/reference/plus/giftcard#search -- not clear to me

 

Any guidance would be appreciated.

0 Likes

Success.

Shopify Staff
Shopify Staff
298 32 59

Hey Joerz,

 

Our search syntax documentation includes all information about how to construct your queries for the "/search.json" endpoints on the Customer and Gift Card resources.

 

If you are looking to search for all gift cards which have been updated after a certain point, you would use the "query" parameter in conjunction with the "updated_at" field.

 

For example, if you are looking to construct a search for all gift cards which have been updated in 2019 (EST), your query would look like:

GET "/admin/gift_cards/search.json?query=updated_at:>"2019-01-01T00:00:00-05:00"

The :< operator is used for less-than and the :> operator is used for greater-than. It's also important to note that the date value needs to be a string surrounded by quotation marks.

 

 

1 Like
Shopify Partner
6 0 0

@Zameer thanks so much - i appreciate the exact answer.  My apologies for missing the search docs. 

 

Kudos to you!  Sincere thanks...

0 Likes
New Member
2 0 0

hi Zameer

 

I'm trying this

https://myshop.myshopify.com/admin/gift_cards/search.json?query=updated_at:>"2019-05-15T04:36:44.948..."

Which returns Invoke-RestMethod : The remote server returned an error: (500) Internal Server Error.

 

https://myshop.myshopify.com/admin/gift_cards/search.json?query=updated_at:>2019-05-15T04:36:44.9482...

This returns no gift cards and no error.

 

Can you help please, I'm using Invoke-RestMethod within powershell.

 

Thanks Orhan

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
298 32 59

Hey Orhan,

 

Are you still receiving the 500 error? Typically, we recommend that you retry the query after some sort of set time period in case the issue is database related.

 

The syntax with the quotation marks is the correct syntax.

 

If you're also able to provide me with the 'X-Request-Id' header for the failing query I can dig in deeper.

0 Likes
New Member
2 0 0

Hi Zameer

 

Issue seems to be resolved. I just need the date with no time and timezone.

admin/gift_cards/search.json?query=updated_at>"2019-01-01"

 

Thanks Orhan

0 Likes