Unable to update price of item

Solved
NothingButPOS
Tourist
4 1 0

I am trying to update a price of a variant. 

I am PUTting to:

/admin/api/2020-04/products/4887574085772.json

My body is:

{
  "product": {
    "id"4887574085772,
    "title""Blah Blah Blah",
    "variants": [
      {
        "id"33345081344140,
        "price""43"
      }
    ]
  }
}

I simply get the following error as a response:

{
    "errors": {
        "product""Required parameter missing or invalid"
    }
}

 

P.S. Presuming I can get the above working, how would I go about updating the cost price as well?

0 Likes
_JB
Shopify Staff
Shopify Staff
834 98 188

Hey @NothingButPOS,

That call looks like it should work, can you kindly provide the X-Request-ID value from the response headers of your failed call? I'll use this to check the logs and see if there's more information to be found there. As well, please add the parameter ?debug=true to the URL before making the call as this will give us more info in the logs.

The cost field for variants lives on the inventory_item object, so you need to call the Inventory API to update this field. 

JB | Developer 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

0 Likes
NothingButPOS
Tourist
4 1 0

Thanks JB.

Here's an X-Request-ID to trace: 0ca8d656-7c07-4531-913b-875858b679e9

What's odd this morning is that I can actually get the call to work in Postman but not my app (whereas yesterday both seemed to be failing).  No doubt it's probably something simple my end, but i'm tiring of looking at the code.

 

0 Likes
NothingButPOS
Tourist
4 1 0

Another ID for good measure: 797df9a3-de21-484d-b5a0-2c56fdf6684c

0 Likes
NothingButPOS
Tourist
4 1 0

This is an accepted solution.

Solved:

I think I simply needed to add Content-Type=application/json to the header. 

 

All works well now, including the cost price, thanks for your help.

0 Likes