Having trouble with Flow creating a collection on product quantity change?

FurtherRecords
Excursionist
30 1 14

I'm not experienced with API at all before this but I'm trying to make flow create a collection when a product quantity is changed (a pretty common trigger for me). The flow is getting stuck (not erroring) returning:

 

Did this...

Send HTTP request
Jan 20, 2023 at 06:15 PM

Retrying

Devs told me to use Send HTTP Request to call this API: https://shopify.dev/api/admin-graphql/2023-01/mutations/collectionCreate so I entered that as the The URL of the HTTP request.

My headers are:

Content-Type:application/json

X-Shopify-Access-Token:[hidden]

(I got the token from a private app I created with access to read/write products)

 

The body is:

mutation {
  collectionCreateV2(input: {
    title: "{{product.vendor}}",
    handle: "{{ product.vendor | downcase | replace: ' ', '-' | remove: '(' | remove: ')' | strip_html }}",
    ruleSet: {
      appliedDisjunctively: false,
      rules: [
        {
          column: "VENDOR",
          relation: "CONTAINS",
          condition: "{{product.vendor}}"
        }
      ]
    },
    sortOrder: "CREATED_AT_DESC"
  }, query: "title:{{product.vendor}} AND handle:{{ product.vendor | downcase | replace: ' ', '-' | remove: '(' | remove: ')' | strip_html }}") {
    collection {
      id
      title
      handle
    }
  }
}

Any idea's what might be wrong? I've relied almost entirely on chatGPT to get this far!

 
Replies 2 (2)

paul_n
Shopify Staff
1072 137 255

It's retrying because you got a 500 type message (but will eventually fail with an informative error message). If that is the URL you are using, then you have the wrong URL as a start. I think there are also multiple things wrong in your query, but to be honest this is like trying to fix a car that has all the wrong parts already. I'd recommend when testing an API, you start with an API client like Postman or Insomnia and get the query working. Then you port that over to Flow. And start small by using the smallest number of fields and build on complexity from there.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
FurtherRecords
Excursionist
30 1 14

Thanks. I changed the URL to https://further-records.myshopify.com/admin/api/2023-01/graphql.json and also tried https://further-records.myshopify.com/admin/api/graphql.json

 

Both returned 400 errors. I've tried a very simple "create-test-collection" to those URLs too but no luck (with either Flow or Postman).

 

 

 

 

mutation {
  collectionCreate(input: {
    title: "Test Collection",
    handle: "test-collection"
  }) {
    collection {
      id
      title
      handle
    }
  }
}

 

 

 

 

EDIT> Sent a GET request to those URLs and got 404 on both. So I guess either the URL is wrong or I'm not correctly authenticated to access it.

 

EDIT2> Managed to get a 200 response with a query. Making progress!

 

EDIT3> Test Collection & Test Collection 2 created. So far no luck with the automated ones.