Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing the X-WC-Store-API-Nonce header. This endpoint requires a valid nonce. Postman Error

POST : xyz.com/wp-json/wc/store/cart/add-item I'm Developing a mobile woocommerce application and try to add-item in cart but getting some error please help to fix this problem thanks.

In Body:
  
{
"id": "8924",
"quantity":1,
"variation": [
             {
              "items" :{
              "attribute": "hj",
              "value": "knk"
              }
           }
        
           ]
        }

Error:
{
 "code": "woocommerce_rest_missing_nonce",
 "message": "Missing the X-WC-Store-API-Nonce header. This endpoint requires a valid nonce.",
 "data": {
 "status": 401
        }
}
like image 218
Permendra Singh Avatar asked Nov 16 '22 05:11

Permendra Singh


1 Answers

You need to pass back a nonce as a header, previously X-WC-Store-API-Nonce, now just Nonce.

A nonce is required on all POST requests and all requests to store/checkout. You can get a nonce on every response you get from the server, so if you hit store/cart, you will get a nonce, save that nonce and use it for future requests, but make sure to update it after each response.

like image 125
N. Seghir Avatar answered Jan 09 '23 23:01

N. Seghir