I want to send the information entered in my form to my database when the submit button is clicked
<button onclick="submitIntervention()" class="btn btn-primary" type="submit">Submit</button>
to do so I make a ajax call inside my submitIntevention() in my view like this.
$.ajax({
url: 'https://API-CALL-GOES-HERE',
type: 'POST',
data: JSON.stringify(interventionData),
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "HEAD, GET, POST, PUT, PATCH, DELETE",
"Access-Control-Allow-Headers": "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With",
"Accept": "application/json",
"Content-Type": "application/json"
},
At first I was having problems with Cors so I went on Azure and allowed everything to go through with the '*' and added this code to my API startup.cs file.
services.AddCors(policy => policy.AddPolicy("Policy", builder =>
{
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
}));
app.UseCors("Policy");
Since then I stopped getting the Cors error but I get the internal 500 one. I read about checking my logs to find the mistake but not quite sure how to go about this since I'm a beginner. thanks for your time.
EDIT (azure Cors configuration of my api)
EDIT 2
When I comment out the "Content-Type" line I get the 415 error for the unsupported media type which makes me think there's a problem there