A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am trying to create a new variant and it is not happening.
Getting 200 response messages but no JSON object as a variable in postman
/{products/6951116406924/variants.json
the URL is {{BaseURL}}products/6951116406924/variants.json
Hi there!
I don't know why you are not getting any response, when I replicated the request you are describing I did get an error message, "Expected Array to be Hash".
That error message is because of some incorrect formatting of your POST Body. You should remove the square brackets.
{
"variant":
{
"title": "210000011628",
"price": "20.00",
"sku": "210000011628"
}
}
You should also verify that you are sending it as a POST request not a PUT.
With that POST body, and the url structure you specified I was able to successfully create a variant.
To learn more visit the Shopify Help Center or the Community Blog.
Hi,
Thanks for your reply, let me try that, what is wrong with this when you try to send multiple Variant while creating the product
Can you share your postman call screenshot, is there anything to do in postman to replicate the error you were getting, I am using API version 2020-07
{
"product" : {
"published_scope" : "global",
"title" : "TW Test Boomi Sync Parent 2",
"variants" : [
{
"inventory_management" : "shopify",
"price" : "20.0",
"sku" : "210000011628",
"title" : "TW Test Boomi Sync Parent 2",
"weight" : 0,
"weight_unit" : "lb"
},
{
"inventory_management" : "shopify",
"price" : "20.0",
"sku" : "210000011629",
"title" : "TW Test Boomi Sync Parent 2",
"weight" : 0,
"weight_unit" : "lb"
},
{
"inventory_management" : "shopify",
"price" : "20.0",
"sku" : "210000011630",
"title" : "TW Test Boomi Sync Parent 2",
"weight" : 0,
"weight_unit" : "lb"
}
],
"status" : "draft"
}
}
Thanks
Akber Ali
still not resolved
I have a couple of questions
1) What are you using as your baseurl?
2) Are you sending cookies with your request? Try removing the cookies that are being sent with the request. You should see this option below the send button
I would also recommend looking at the code sample here "Create new product with multiple variants".
https://shopify.dev/api/admin-rest/2022-04/resources/product#post-products
You can copy the curl request, go to postman > Import > Paste Raw to import the already formatted request to Postman.
To learn more visit the Shopify Help Center or the Community Blog.
1. BaseURL is a postman variable to the actual URL of shopify.
2. I have removed the Cookies as suggested, but now the response code changed to 406 Not Acceptable. I Selected the Accept as application/json and unselect same error
Yup, I understand that the baseurl is a variable. I was wondering what the value of the variable is so that I could double check it for you! 🙂
If you are getting a 406 that means you are on the right track! That means that something is not formatted correctly with the request.
I would recommend that you take a look at the example I posted in my previous reply, and then build your request off of the working example!
To learn more visit the Shopify Help Center or the Community Blog.
Hi lizk,
Here is the BaseURL, I have hide the company info
Even though sent what you typed above but has same result.
Your BaseUrl looks correct!
But that data looks a little different than the example? I would first recommend testing out the example, getting that working 100%, then modifying it based on your needs.
For connivence here is the example request. You can import this into postman by going Import > Raw Text > and then pasting this in!
curl --location --request POST 'https://store.myshopify.com/admin/api/2022-04/products.json' \
--header 'X-Shopify-Access-Token: shpat_b' \
--header 'Content-Type: application/json' \
--data-raw '{"product":{"title":"Burton Custom Freestyle 1512","body_html":"\u003cstrong\u003eGood snowboard!\u003c\/strong\u003e","vendor":"Burton","product_type":"Snowboard","variants":[{"option1":"First","price":"10.00","sku":"123"},{"option1":"Second","price":"20.00","sku":"123"}]}}'
To learn more visit the Shopify Help Center or the Community Blog.
I just ran the Product with Variant and now getting an error:
Sorry, I just updated the request in the comment.
You can also grab this from the docs as well!
https://shopify.dev/api/admin-rest/2022-04/resources/product#post-products
To learn more visit the Shopify Help Center or the Community Blog.