FROM CACHE - en_header

Discount Code lookup endpoint REST API

Demos
New Member
3 0 0

I tried using the discount code lookup endpoint to get the location of discount code that already exists in my store but could not find the location header to get the response.

 

How are we supposed to get the header? 

Replies 6 (6)
KarlOffenberger
Shopify Partner
1873 184 868

Hi, could you elaborate a little more what you mean by location header of a discount code?

 

Discount codes are bund to a price rule which you will find referenced in the discount code itself, along with the code itself and how often it was used. I don't see how location comes in to play here?

 

Best wishes!

Liked this post? You might also like our fantastic upsell apps Candy Rack, Last Upsell post-purchase and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
Demos
New Member
3 0 0
Hi there I am referring to the retrieve discount location by code endpoint:

admin/discount_codes/lookup.json?code=SUMMERSALE10OFF


Is even states:

"Retrieves the location of a discount code.

The discount code's location is returned in the location header, not in the DiscountCode object itself. Depending on your HTTP client, the location of the discount code might follow the location header automatically."

KarlOffenberger
Shopify Partner
1873 184 868

Ah I get you. That endpoint returns a 303 aka see other status. What that means is basically that if the discount code is found, the header contains a URI to the actual resource - if you're testing this via Postman or Insomnia, it's likely you're being redirected straight away to that resource hence you see a 200 and nada else.

 

Don't know about Postman, but Insomnia you will find the request timeline which will clearly show the initial 303 response which includes he location in the header.

 

Hope this helps!

Liked this post? You might also like our fantastic upsell apps Candy Rack, Last Upsell post-purchase and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
Demos
New Member
3 0 0
Thank you that makes sense then. How would you capture the 303 header before it redirects?
trevoruptain
New Member
1 0 0

In Postman, just go to Preferences > General and turn off "Automatically follow redirects"

chrisfloat
Tourist
20 0 3

Hi Karl,

this is kind of the same topic but a little different. 

I need to get a price rule id. I need to look for a specific coupon and get the price rule id that it is based on.

how would you try to solve this issue?