What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Price Rule: Required parameter missing or invalid

Price Rule: Required parameter missing or invalid

mark_macrae_
Shopify Partner
11 1 6

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 6

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

Morek
Shopify Partner
835 73 179

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.

If you're looking for a Shopify developer or just want to connect, don't hesitate to reach out!
Portfolio: https://mmorek.com/
LinkedIn: https://www.linkedin.com/in/mmorek
WhatsApp: Whatsapp me!