Development discussions around Shopify APIs
Hi everyone,
I'm trying to update my product price through the product variant using Postman. Does anyone know the required parameters?
I'm using the payload from the documentation (https://shopify.dev/docs/admin-api/rest/reference/products/product-variant#update-2020-10).
https://{{api_key}}:{{password}}@{{store}}.myshopify.com/admin/api/2020-10/variants/{{variant_id}}.json
This is Postman's response:
{
"errors": {
"variant": "Required parameter missing or invalid"
}
}
Thanks in advance!
Solved! Go to the solution
This is an accepted solution.
Make sure you are using the PUT method, not the POST method... (don't know if that is the case but it is a common gotcha!) For other readers: https://shopify.dev/docs/admin-api/rest/reference/products/product-variant#create-2020-07
In our experience, it is a good idea to first do a GET on the same endpoint, this will then return the current product data structure. You can then edit the fields you want to change and use this as the POST data, that ensures that your schema is always up to date! Use a tool like Postman for more detailed response data, before you chuck it into your application!
Sounds like you have a "required" feedback in your variant that you haven't included in the PUT request body...
Can you please supply your JSON request body you are sending?
This is an accepted solution.
Make sure you are using the PUT method, not the POST method... (don't know if that is the case but it is a common gotcha!) For other readers: https://shopify.dev/docs/admin-api/rest/reference/products/product-variant#create-2020-07
In our experience, it is a good idea to first do a GET on the same endpoint, this will then return the current product data structure. You can then edit the fields you want to change and use this as the POST data, that ensures that your schema is always up to date! Use a tool like Postman for more detailed response data, before you chuck it into your application!
Sounds like you have a "required" feedback in your variant that you haven't included in the PUT request body...
Using the GET method first did the trick. I made a format error in the PUT request body.
It looks like it doesn't have any required fields either. I was able to update the price without entering anything else.
So this still worked in Postman:
PUT https://{api_key}:{password}@{store}.myshopify.com/admin/api/2020-10/variants/{variant_id}.json
{
"variant": {
"price": "999.00"
}
}
Thanks a lot for the help!
User | RANK |
---|---|
49 | |
11 | |
5 | |
5 | |
5 |
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023