Price Rules: Error: Required parameter missing or invalid

Highlighted
Tourist
4 1 3

I am getting an error "Required parameter missing or invalid" when I try to create a new price rule. How do I get more information about which parameter is missing or invalid? Or, can you help me identify the issue? Thank you!

POST /admin/price_rules.json HTTP/1.1
Host: pacific-gourmet.myshopify.com
Authorization: Basic ****************************
Cache-Control: no-cache
Postman-Token: ****************************

{
  "price_rule": {
    "title": "decrease10",
    "target_type": "line_item",
    "target_selection": "entitled",
    "allocation_method": "across",
    "value_type": "percentage",
    "value": "-10",
    "once_per_customer": false,
    "usage_limit": null,
    "customer_selection": "prerequisite",
    "prerequisite_subtotal_range": null,
    "prerequisite_shipping_price_range": null,
    "prerequisite_saved_search_ids": [
      1796588609
    ],
    "entitled_collection_ids": [
      332465537
    ],
    "starts_at": "2017-06-13T17:20:59Z",
    "ends_at": null
  }
}

I also tried using the example code from the price rule API documentation (https://help.shopify.com/api/price-rules#tag/Price-Rule%2Fpaths%2F~1admin~1price_rules.json%2Fpost), but get the same error.

{
  "price_rule": {
    "title": "string",
    "target_type": "line_item",
    "target_selection": "all",
    "allocation_method": "across",
    "value_type": "fixed_amount",
    "value": null,
    "once_per_customer": true,
    "usage_limit": null,
    "customer_selection": "all",
    "prerequisite_subtotal_range": null,
    "prerequisite_shipping_price_range": null,
    "prerequisite_saved_search_ids": [
      0
    ],
    "entitled_product_ids": [
      0
    ],
    "entitled_variant_ids": [
      0
    ],
    "entitled_collection_ids": [
      0
    ],
    "entitled_country_ids": [
      0
    ],
    "starts_at": "2017-06-13T18:41:16Z",
    "ends_at": null
  }
}

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1555 81 287

Hey Nile,

I've been able to replicate your request successfully using Postman. Can you confirm that your body data type is raw, JSON(application/json)? I've run into your issue when there were newline characters and other oddities in copy/pasted request body contents I had placed there.

Cheers.

0 Likes
Highlighted
Shopify Partner
17 0 3

EDITED: figured it out

0 Likes
Highlighted
New Member
2 0 0

What did you figure out?  I'm having the same issue and did the same test trying to submit the example using php cURL.  

0 Likes
Highlighted
New Member
2 0 0

I figured my issue out, in PHP I needed to add the following header:

 

 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
0 Likes