Price Rule: Required parameter missing or invalid

mark_macrae_
Shopify Partner
11 1 3

Sorry guys... that error message is completely unhelpful.  Which parameter is missing or invalid in this API call?  None of the parameters are marked as "REQUIRED" in the documentation.  I have tried adding the "Starts_At" parameter which made no difference.  I would expect the default to be "now" when the rule is created anyway, but of course the documentation doesn't say.

/admin/api/2021-04/price_rules.json

POST

 

{
    "price_rule": {
        "title": "SQJUNXJMSS40",
        "target_type": "line_item",
        "target_selection": "all",
        "allocation_method": "across",
        "value_type": "percentage",
        "value": "40",
        "customer_selection": "prerequisite",
        "prerequisite_customer_ids": [
            "5241665683638"
        ]
    }
}

 

Replies 2 (2)
mark_macrae_
Shopify Partner
11 1 3

So far I have figured out:

  • yes "starts_at" is required.
  • "value" must be a negative value
  • there is something wrong with the way PHP is encoding the "prerequisite_customer_ids"

I can successfully create a price rule only if I set "customers_selection" to "all".

I am using the shopify_call() from this GIT Hub: https://github.com/nyalex/shopify-generating-api-token-guide

Michal17
Shopify Partner
835 73 171

Hi @mark_macrae_ 

Hope you're having a great day!

As specified by Shopify:

The "value" must be negative.

So try this:

 

 

{
    "price_rule": {
        "title": "SQJUNXJMSS40",
        "target_type": "line_item",
        "target_selection": "all",
        "allocation_method": "across",
        "value_type": "percentage",
        "value": "-40.0",
        "customer_selection": "prerequisite",
        "prerequisite_customer_ids": [
            "5241665683638"
        ]
    }
}

 

 

If you have any further questions, please do reach out either here on the forum, or via a private message/email.