2

I'm trying to update a particular product in Magento through PUT using python. I'm using OAuth1Service for authentication to Magento 2. GET products is actually giving me all the products in Magento where as PUT payload is not taking payload.

My payload is a JSON string

'''{
 "product": {
 "price": 1,
 "extension_attributes": {
 "stock_item": {"qty": 2}
 }
 }
}'''

My put request looks like this, the headers has the authentication token and the content type inside it.

payload = json.loads(product)
r = session.put(
'products/12345',
headers=headers,
data=json.dumps(payload),
)

Rather than taking the payload, it is giving me this error:

enter image description here

mtr.web
9107 silver badges18 bronze badges
asked Apr 27, 2019 at 7:55

1 Answer 1

1

Magento is trying to load the product by SKU but you didn't send it in your Json. Even though you are passing the SKU on your URL, SKU is still a required field. , try with:

{
 "product": {
 "price": 1,
 "sku": 12345,
 "extension_attributes": {
 "stock_item": {"qty": 2}
 }
 }
}

Here in swagger is showing that SKU is required. Follow swagger for your next requests.

Swagger tutorial

answered Apr 28, 2019 at 3:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.