Umbraco Forms Headless antiforgery tokens always r...
# help-with-umbraco
b
I'm trying to use the Umbraco Forms headless API to insert a row into a form. When I run this code I still get an error "The required antiforgeryToken is not present"
Copy code
// security header
            requestMessage.Headers.Add("Api-Key", _options.CurrentValue.FormsKey);

            var response = await _httpClient.SendAsync(requestMessage);
            if (!response.IsSuccessStatusCode)
            {
                _logger.LogError("Umbraco Forms API did not return successful while adding record for newsletter, response {Response}",
                    await response.Content.ReadAsStringAsync());
                return false;
            }
Even though I have these appsettings:
Copy code
"Options": {
        "EnableFormsApi": true,
        "EnableAntiForgeryTokenForFormsApi": false,
      },
      "Security": {
        "FormsApiKey": "[the correct key]"
      }
Is anyone familiair with how to fix this issue? I've even tried turning AntiForgery tokens off completely by using the Options:EnableAntiForgeryToken to false but this also doesn't work.
f
Hi did you resolve your problem ? I am also building a headless form for nextJs. Do you have may be an example ?
12 Views