Solved

Create a product with variants and options using REST API and Integromat / Make

NolkOS
Visitor
3 0 4

Hello!

 

I'm trying to create an automation that will take a product record I have in an Airtable database and push it into Shopify to create a new product with variants and options. I keep getting a 400 error, but can't find what parameter(s) I'm missing.

 

Here's the POST API call I'm trying to use.

Here's the JSON I'm using in the API call:

{"product":{"title":"Test Product","body_html":"This is a test being run on July 14th, 2022,\n\n# Heading one\n## Heading two\n### Heading three\n1. Numbered\n2. List\n3. of \n4. Items\n- Bullet point\n- list\n- of\n- items\n\n**Bold Text.**\n**_Italicized bold._**\n_Italicized text._\n","vendor":"Nolk OS","product_type":"Product","variants":[{"option1":"Small","option2":"Red"},{"option1":"Large","option2":"Red"},{"option1":"Small","option2":"Blue"},{"option1":"Large","option2":"Blue"}],"options":[{"name":"Size","values":["Small","Large"]},{"name":"Color","values":["Red","Blue"]}]}}

...and this is what it looks like in a JSON viewer:

Screen Shot 2022-07-19 at 8.32.21 AM.png

For reference, the example JSON shown in the API doc looks like this:

{"product":{"title":"Burton Custom Freestyle 151","body_html":"<strong>Good snowboard!</strong>","vendor":"Burton","product_type":"Snowboard","variants":[{"option1":"Blue","option2":"155"},{"option1":"Black","option2":"159"}],"options":[{"name":"Color","values":["Blue","Black"]},{"name":"Size","values":["155","159"]}]}}

...and looks like this in a JSON viewer:

Screen Shot 2022-07-19 at 8.33.53 AM.png

So far, so good, I think. I'm then inserting this JSON into an HTTP module in Integromat, looking like this:

Screen Shot 2022-07-19 at 8.15.06 AM.png

After running the scenario, the input for that module looks like this:

Screen Shot 2022-07-19 at 8.14.47 AM.png

And for whatever reason, I keep getting this error on the output:

OUTPUT

 

  • Bundle 1Collection
    • Status code
      400
    • HeadersArray
    • Cookie headersArray
      Empty
    • DataCollection
      • errorsCollection
        • product
          Required parameter missing or invalid

I'm using a custom app (not private) for my API access, running the latest release of the API, and I've tested the connection with GET calls, which have no issues. I've also ensured that the app has the correct permissions scope to read and write products (and product listings) in Shopify.

 

Can anyone see what I'm missing here?

Thanks!

Accepted Solution (1)

JamesG
Shopify Staff
42 10 10

This is an accepted solution.

Hey @NolkOS ,

 

It looks like the API client you are using is wrapping the body of your request in an array and causing the 400 error:

 

22-06-eng32-bh5i5

 

I tested the same request with a test store using Postman with the body formatted as an object and had no issues:

 

22-10-fwvgy-xy53c

 

Cheers,

JamesG | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 2 (2)

JamesG
Shopify Staff
42 10 10

This is an accepted solution.

Hey @NolkOS ,

 

It looks like the API client you are using is wrapping the body of your request in an array and causing the 400 error:

 

22-06-eng32-bh5i5

 

I tested the same request with a test store using Postman with the body formatted as an object and had no issues:

 

22-10-fwvgy-xy53c

 

Cheers,

JamesG | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

NolkOS
Visitor
3 0 4

Thanks so much @JamesG! Solved and working now. 

 

For anyone wondering why I didn't just use the built-in module for Shopify from Integromat: I'm using this installation for multiple stores, and I wanted to have a store-agnostic workflow where I could pass API credentials into the scenario instead of duplicating the scenario for each store.