Usually, this error is caused by missing or expired form digest. if you aren’t using OAuth to authorize your requests, these operations require the server’s request form digest value as the value of the X-RequestDigest header
You can retrieve this value by making a POST request with an empty body to
http://<site url>/_api/contextinfo. Or you can directly get it through the SharePoint control ‘#__REQUESTDIGEST’ if your code is running in a SharePoint page.
CLICK HERE to find out more related problems solutions.