
How should I access an post request in the URL ?
Here I tested a student id that is not registered before but id did not work ?
There is not problem in the student logic and stuff like that my problem is how to access POST request from the URL ?
Here is the code :
app.MapPost("/student/{id}", (Student newStudent, int id) =>
{
if (StudentDB.students.ContainsKey(id))
{
return Results.BadRequest(new ProblemDetails
{
Title = "Student already exists",
Detail = $"A student with id {id} already exists"
});
}
StudentDB.students.Add(id, newStudent);
return Results.Created($"/student/{id}", newStudent);
});