Product variant update

Solved
michaelR
New Member
2 0 1

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!

Accepted Solution (1)

Accepted Solutions
ejb503
Shopify Partner
19 3 3

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...

YownIt: Welcome to the eCommerce marketplace with one click install, integrated video, audio and chat. Engage with your customers online and offline with multi-channel conversion tools. Available in the App store: https://apps.shopify.com/the-shop-front

View solution in original post

Replies 3 (3)
Gregarican
Shopify Partner
1030 86 276

Can you please supply your JSON request body you are sending?

ejb503
Shopify Partner
19 3 3

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...

YownIt: Welcome to the eCommerce marketplace with one click install, integrated video, audio and chat. Engage with your customers online and offline with multi-channel conversion tools. Available in the App store: https://apps.shopify.com/the-shop-front
michaelR
New Member
2 0 1

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!