422 and 400 error code

Highlighted
New Member
2 0 0

HI,

I am just trying to understand the different when I can expect a 422 and when I can expect a 400.

consider the following scenarios:

* An invalid value for a query parameter in the URL?

* An invalid value for a field in the post body?  For example, suppose it has a max value of 10 and I send up 11

* Missing a required field in the post body?

* Sending up the wrong type for a field - it's a String and I send up a Boolean.

 

Thanks

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
491 97 88

Hey @Breako 

 

In relation to the API? The best route will be to test it, which will give you the certainty of the response and how to handle it. We list the response codes and write-ups here: https://www.shopify.dev/concepts/about-apis/response-codes For example...

  • if I sent a GET for https://shop.myshopify.com/admin/api/2019-10/orderz/count.json I would get a 400 
  • If I did a POST to https://shop.myshopify.com/admin/api/2019-10/price_rules.json with the response body like the following: 
    {
      "price_rule": {
        "title": "SALE",
        "target_type": "line_item",
        "target_selection": "fall",
        "allocation_method": "across",
        "value_type": "fixed_amount",
        "value": "-10.0",
        "customer_selection": "all",
        "starts_at": "2017-01-19T17:59:10Z"
      }
    }
    Where fall is substituted for all I will get a 422 with the relevant error 
        "target_selection": [
          "is invalid"
        ]

 

 

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


0 Likes
Highlighted
New Member
2 0 0

Thanks for this.  The reason I ask is I am  technical blogger (http://dublintech.blogspot.com/)  and thinking about doing a blog post on 400 V  422.  Any more general info much appreciated. 

 

0 Likes