Api api/2023-04/price_rules.json return array instead an single object

Api api/2023-04/price_rules.json return array instead an single object

cubissimo
Shopify Partner
3 0 3

Hi, im trying to use the api:

[POST] https://{domain}/admin/api/2023-04/price_rules.json

 

as specified here: https://shopify.dev/docs/api/admin-rest/2023-04/resources/pricerule#post-price-rules


but im receiving an array with all codes instead the created price rule.
i can confirm that no creating any price rule at all.

Can you help me with that? Follow de request id.
X-Request-ID: 47a1cdd5-ca53-44c5-930d-9dfbef354318

Tks

Replies 7 (7)

lizk
Shopify Staff
246 58 79

Hi there 👋

When I review the logs for that X-request-id, it is a request being made to GET "/admin/api/2023-04/price_rules.json
So that would make sense that it is returning a list of Price Rules.

Do you have the code for the request that you are trying to make that you would like me to review? 



To learn more visit the Shopify Help Center or the Community Blog.

cubissimo
Shopify Partner
3 0 3

Im Just checked out that i sending a post request. 

Im using postman just to make sure everything is fine, follow the screenshot

cubissimo_0-1689278442096.png

 

lizk
Shopify Staff
246 58 79

If this is not working could you share
1) The request body 
2) The request response
3) The X-request-id

To learn more visit the Shopify Help Center or the Community Blog.

admchrs1
Tourist
9 0 3

Hi, thanks for your help. I have the same problem and right now. I'm using POST method, my body: 

const requestBody = {
  price_rule: {
    title: 'TEST10',
    target_type: 'line_item',
    target_selection: 'entitled',
    entitled_product_ids: [5419639406749, 8167846412514],
    allocation_method: 'across',
    value_type: 'percentage',
    value: -10.0,
    usage_limit: 1,
    starts_at: isoStartDate,
    ends_at: isoEndDate,
    customer_selection: 'all'
  }
};
the request response is far to big for me to send it here but it's an array of existing price rules (and my price rule isnt in it), other than that, it's just typical price rules.
endpoint: 
X-Request-Id: e54bf548-5fdb-4259-8f53-cdb1e7db694f
 
Access scopes:
- read/write price rules
- read/write discount codes
- read analytics

amir-club
Shopify Partner
4 0 3

Hello,

I'm facing the same issue. anyone were able to solve it?

cubissimo
Shopify Partner
3 0 3

Nothing so far.. we terminating declining the customer contract because of this bug.

amir-club
Shopify Partner
4 0 3

 it turns out it only happens when we call the main domain but it doesn't happen when we call myshopify domain. so probably a bug on the redirection where the POST requests end up turning into GET requests