Smart Collection Create Error

44 9 11



I'm a little baffled to the following error and I don't understand what is the issue.


I'm trying the following code in the dev console:


  url: '/admin/api/2019-07/smart_collections.json',
  type: 'POST',
  dataType: 'JSON',
  data: {
    "smart_collection": {
      "title": "IPods",
      "rules": [
          "column": "title",
          "relation": "starts_with",
          "condition": "iPod"
.done(data => {
  console.log("success", data);
}).error(data => {

But I get an error:

{"errors":{"rules":"expected Hash to be a Array"}}

I'm not blind but the rules are array so I don't know what the heck is his problem.


The Form Data that is submitted is:

smart_collection[title]: IPods
smart_collection[rules][0][column]: title
smart_collection[rules][0][relation]: starts_with
smart_collection[rules][0][condition]: iPod

Which seems OK.


The example is taken from here:[version]=2019-07#create-2019-...


I tried to stringify the object but then the whole data is not ok then.


Can someone give some insight since I don't know what to try anymore?


PS: As I mentioned the code is pasted in the chrome dev tools, it's not separate APP, so there is no need for Access Token or something else.

Shopify Staff
Shopify Staff
1125 78 159

Hey @ikolarov , 


I wanted to take a moment to recommend against making API calls from a storefront, it's insecure and not something we really support or encourage doing. 


With regards to the call you were having issues with though, I copy and pasted your API call and sent it with an HTTP client called Insomnia and it worked fine. So I don't think it's the body of the API call itself causing the problem. Would you be interested in giving Insomnia or Postman a try to send these calls? I think you'd have a much easier time. 

44 9 11

Hi @Josh 


I'm was creating a script for a client where I needed to clone a lot of collections, so I'm using the dev console like I mentioned, not the storefront. This was one time script that loops all collections and clone them with additional data attached to them.


It's easier to create a script for the console instead of a full blown app that will be used for a simple script one time. I'm just showing the problem part in the question and not the whole code maybe that's why it was confusing.


This script is the same as a bookmarklet but instead it's pasted in the console.


Postman will work for a single request but not for a whole script, the same applies for Insomniac.


Just to clarify again I'm going to my Admin Dashboard, I open my Chrome Dev Console and I paste the scrip there: 



Let me know if it's not clear.