A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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:
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:
So far, so good, I think. I'm then inserting this JSON into an HTTP module in Integromat, looking like this:
After running the scenario, the input for that module looks like this:
And for whatever reason, I keep getting this error on the output:
OUTPUT
Bundle 1Collection
Status code400 HeadersArray Cookie headersArrayEmpty DataCollection
errorsCollection
productRequired 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!
Solved! Go to the solution
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:
I tested the same request with a test store using Postman with the body formatted as an object and had no issues:
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
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:
I tested the same request with a test store using Postman with the body formatted as an object and had no issues:
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
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.