Price Rule API authentication issue for POST

vtdev
New Member
4 0 0

Hi,

 

I've been using the Price Rule API for a few months until now, it just doesn't work anymore!!!  No resources online, no support available. I'm wondering if it's happening to anyone else. I appreciate any help.

 

https://help.shopify.com/en/api/reference/discounts/pricerule#create

I'm using BASIC authentication my passing username and password in the header, my app has "write_price_rules".

The GET method works fine!

 

POST https://myapp.myshopify.com/admin/api/2019-04/price_rules.json

Here's my payload:

{
"price_rule": {
"title": "NEWPRICERULE",
"target_type": "line_item",
"target_selection": "all",
"allocation_method": "across",
"value_type": "percentage",
"value": "-10.0",
"customer_selection": "all",
"allocation_limit": null,
"once_per_customer": true,
"usage_limit": 1,
"starts_at": "2019-05-01T00:00:00-04:00",
"ends_at": "2019-07-31T00:00:00-04:00"
  }
}

0 Likes
dlenselink
New Member
2 0 2

vtdev,

 

I am experiencing what I can only assume is a very similar issue here. When I send a request to the/admin/api/2019-04/price_rules.json endpoint, it returns a 200 OK status, but the returned body doesn't make sense. I can also confirm that after receiving the 200 OK status, when I get the list of all price rules ton confirm the new addition, the new price rule is not among the complete price rule list, so clearly it is not actually getting added.

 

Here is my request body and response:

Screen Shot 2019-06-04 at 1.36.25 PM.png


If my issue is different, feel free to disregard my post. The GET method works fine for me as well.

 

It would be really nice if this obvious change to the API was documented in a place where users have a chance of seeing it (if it is documented at all), considering that there are likely many applications and stores across Shopify's platform which rely on this endpoint. You would think that Shopify would alert users in some way when a change like this goes live.

vtdev
New Member
4 0 0
Hi dlenselink,

Thanks for sharing it. I'm also getting 200 OK status but the body is just
a hyperlink with the text 'continue' redirecting to the original request.
Usually, this happens when the credentials sent for the POST request don't
have access granted to write price rules, in my case I do have this right.
I agree with you that it's not well documented.
0 Likes
dlenselink
New Member
2 0 2
Hi vtdev,

Crazy timing, I was just typing up a follow up to this thread! After some
more googling, I found that there cannot be ANY cookies passed in with the
request. Many threads indicate that this produces the 200 response with the
HTML content. Thanks!
vtdev
New Member
4 0 0

Hi dlenselink,

 
Yeah, it makes sense not to accept cookies in the request for security, in my case I'm testing it using Postman.
Interestingly, it used to work just fine that's why I believe Shopify may have modified something in the backend or not reading correctly my permission to write price rules. 
0 Likes
vtdev
New Member
4 0 0

Not sure how but it's working fine now. The only new attempt on my side was deleting the generated cookies from Postman. 

I couldn't figure out why it was also failing the POST request from Zapier with no cookies.

 

0 Likes
Pallavi
Shopify Expert
2366 396 512

Hello Vtdev, 

 

I am getting some issue on GET method so could you kindly assist me in resolving it.

Want to modify or develop new app, Hire us.
If helpful then please Like and Accept Solution .
Email: support@zestard.com
Shopify Apps URL :- https://apps.shopify.com/partners/zestard-technologies
Custom Modifications Into Shopify Theme | Shopify Private App | SEO & Digital Marketing
0 Likes