GET returns 200 with HTML login page

Solved
Tourist
11 0 1

I've seen lots of posts about POST requests receiving an HTML login response but I'm trying a GET and receiving same.

 

Following some SO advice I found on teh webs I set up a policy to prevent cookie use regardless. My request looks like this:

 

from http import cookiejar 
class BlockAll(cookiejar.CookiePolicy):
    return_ok = set_ok = domain_return_ok = path_return_ok = lambda self, *args, **kwargs: False
    netscape = True
    rfc2965 = hide_cookie2 = False

S = requests.Session()
S.cookies.set_policy(BlockAll()

def get_discounts(price_rule):
    req = S.get(url=f'https://{KEY}:{PWD}@{SHOP_NAME}.myshopify.com/admin/api/{API_VERSION}/price_rules/#{price_rule}/discount_codes.json')
    print(f'res: {req.text}')
    print(f'code: {req.status_code}')

get_discounts('FNF')

... any idea what I'm doing wrong here? 

 

Thanks in advance.

0 Likes
Shopify Staff
Shopify Staff
190 21 21

 

Hey @needmoredata 

 

Typically this issue would pop up for a POST request if cookies are being sent. Can you confirm your authentication is correct? Are you able to replicate the problem in Postman / Insomnia? If so, please send the request ID and I can look into this further. 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes
Tourist
11 0 1

Thanks for getting back to me, @vix ... I can replicate this issue in Postman.

 

Request ID: '60f4f03c-a7ee-4113-aee5-5c5755d2d6fd'

 

Thank you.

0 Likes

Success.

Shopify Staff
Shopify Staff
190 21 21

 

Hey @needmoredata Thanks for the reply. 

 

 

I had a look at our logs and I am seeing a misformatted API call in your endpoint. Can you confirm with our docs that you have the correct URL structure: https://help.shopify.com/en/api/reference/discounts/pricerule#show-2019-10 as well as making sure not to include the # with the price_rules_id.

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes
Tourist
11 0 1

Thanks, @vix the # was the issue ... am I misreading the documentation or does it not say you need to precede the ID with a #, as in:

/admin/api/2019-10/price_rules/#{price_rule_id}/discount_codes.json
0 Likes
Shopify Staff
Shopify Staff
190 21 21

 

Hey @needmoredata I do see your confusion, however, that is the standard way in our docs that let you know we are expecting a numerical value. With all of our API endpoints, you will see the same structure. Please leave out the # and add in the ID. 

 

Hope that helps! 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes
Tourist
11 0 1

Thanks for clarifying that @vix ... is there some introductory / style-guide documentation I can check out that includes that sort of thing?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
190 21 21

 

If you're using variables or dynamic inputs, you can think of this like string interpolation. In regards to general Shopify API best practices i'd suggest one of our many guides or our partner blogs

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes