1

I am using magento2 Rest API to update the quantity of product by sku and testing on postman and it gives error

Content-Type header is invalid.400 Bad Request.

I have generated the consumer key, consumer secret, Access token and Access token secret key.

Below are the setting done in postman -:

Method: PUT

URL: http://127.0.0.1/pos_mage/rest/V1/products/{sku_of_product}

Authorisation: OAuth2.0 and set the access token value

Header: Key: Content-Type and Value: application/json

Body: Key: stockItems and Value : 10

But when i am trying to run the API it gives me error

{ "message": "Content-Type header is invalid." } 400 Bad Request.

I am testing on my localhost.

I have checked many tutorial but still not success-:

Magento 2 - REST API PUT product

Why "Invalid Content Type"

Magento 2 Updating Stock via Rest API

saurabh chandela
  • 353
  • 4
  • 12

1 Answers1

1

In the case of a REST API with a JSON payload, 400 error code are typically used to indicate that the JSON is invalid in some way according to the API specification for the service .

Check whether the request contain a valid JSON format or try the following :

ContentType = "application/json" and Accept = "Application/json"
Radwan Badawieh
  • 111
  • 1
  • 3