Try to make this changes
SPWebapplication.FormDigestSettings.Enabled = false to turn off the digest setting property for the web application?
The root cause of this issue and solutions are as below:
The above error will be thrown at the time of updating Library or Lists items due to authentication problem, or We didn’t have the rights to update the items.
By using the following code, We can overcome this issue:
Web.AllowUnsafeUpdates = true;
we can also use the follwoing code to overcome the above error, this will affect the WebApplication. This will change the Security settings of a Web Application to allow the anonymous user to update item.
web.Site.WebApplication.FormDigestSettings.Enabled = false;
web.Site.WebApplication.FormDigestSettings.Enabled = true;
We can change the settings in Central Administration to anonymously update the items. But this method will be dangerous.
Central Administration > Application Management > Web Application General Settings
Choose the WebApplication to overwrite the settings
Select the option Off in Web Page Security Validation as follows,
For detailed please refer the below article:
The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
The security validation for this page is invalid – Infopath 2010