400 Error updating Product variants

GNR_Solutions
Shopify Partner
2 0 0

Hi,

I've been trying to update the product variants on my shopify using the API but I keep getting a 400 error with this text

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

I have written some Java Code to do the API calls for me but I can't seem to get it to work

My Request JSON looks like this

{"product":{"id":8325948040,"variants":[{"compare_at_price":"707.00","price":"693.86","id":27820028616}] } }

Thanks

0 Likes
Kristina
Shopify Staff (Retired)
Shopify Staff (Retired)
46 0 3

Hi there,

Would you mind sharing what your full request looks like, with any confidential info removed? To update a product, you should be sending a request with PUT to /admin/products/{ID}.json, where {ID} is the product ID.

I passed the following and was able to update a product...and it seems similar to what you're passing. I'm wondering if the problem is with the endpoint?

{
  "product": {
    "id": 9202071364,
    "variants": [
      {
        "id": 30894305284,
        "compare_at_price": "2000.00",
        "price": "693.86"
      }
    ]
  }
}

 

0 Likes
GNR_Solutions
Shopify Partner
2 0 0

Hi,

Here is eveything that I send with the request

URL

https://gnr-solutions.myshopify.com/admin/products/8326045512.json

Headers:

  • Authorization: {AUTENTICATION GOES HERE}
  • Accept: application/json
  • Content-Type: application/json
  • Response status code: 400

Time to Response: 1.299
Response

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

Updating JSON

{
  "product":{
    "id":8326045512,
    "variants":[
      {
        "compare_at_price":"169.55",
        "price":"166.38",
        "id":27820219144
      }
    ]
  }
}

 

0 Likes
Kristina
Shopify Staff (Retired)
Shopify Staff (Retired)
46 0 3

This is very strange. I've tried passing the same data format, but with my dev shop, and am receiving a successful update (status 200). I haven't been able to replicate the 400 response...

Are you sending this request with PUT?

0 Likes
mantrahsk
New Member
1 0 0

The only way I can reproduce is when the type is text/plain vs. JSON. Please double-check as I had the issue but now its resolved by correcting that.

0 Likes