PriceRule API POST returns 200

Solved
Highlighted
New Member
1 0 0

Hi,

 

im calling the PriceRule API with a POST request like this:

 

{
"price_rule": {
    "title": "testcode100",
    "target_type": "line_item",
    "target_selection": "all",
    "allocation_method": "across",
    "value_type": "percentage",
    "value": "-10.0",
    "customer_selection": "all",
    "start_at": "2020-04-13T14:00:0Z",
    "once_per_customer": "false"
    }
}

 

Example Request ID: 5677e1d9-e788-4131-89a2-87aa73331694

 

The Response i get is a 200 Code (instead 201) with a result success(1413 bytes).

However the response body is a HTML with a <a href>Continue which looks like it wants me to login, which does not help at all of course.

 

Inside my private app settings i have following settings:

Discounts - Discounts GraphQL API -> Read & Write

Discounts - PriceRule REST and GraphQL API -> Read & Write

 

Im using the REST API inside an iOS Swift project.

 

What exactly is here the problem?

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 124

This is an accepted solution.

Hi @bobbyk ,

 

If you are getting a 200 response that contains an HTML response from the Shopify REST Admin API, chances are the HTML page you are getting is the 'Log In' page asking you to enter your credentials to authenticate with Shopify.

 

This means there is something incorrect with your authentication in your API request. For your POST request make sure you have the "X-Shopify-Access-Token" header set to your private app's password. Read more about how to properly authenticate a private app with the Shopify REST Admin API here: https://shopify.dev/tutorials/authenticate-a-private-app-with-shopify-admin

 

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

0 Likes