mercredi 27 février 2019

Object null POST method Web API

I need your help with an extremely troublesome problem with the web API

When I use Postman to test the POST method of my API and I switch to debug mode, the object received by the method is always null

enter image description here

Here is the code of my DTO :

public class CharacterDTO
{
        public int Id { get; set; }
        [Required]
        public string FirstName { get; set; }
        public string LastName { get; set; }
}

And finally the JSON I'm sending with Postman:

{
    "FirstName" : "John",
    "LastName" : "Snow"
}

If you ever need it, here is the request that Postman makes:

POST /api/characters HTTP/1.1
Host: localhost:49463
Content-Type: application/json
cache-control: no-cache
Postman-Token: 1e303be2-f318-4104-b189-5142fa6ddad6
{
    "FirstName" : "John",
    "LastName" : "Snow"
}
------WebKitFormBoundary7MA4YWxkTrZu0gW--

And the full screenshot of my Postman request :

enter image description here

I hope you have a solution for me because it's just unbearable I can't do anything.




Aucun commentaire:

Enregistrer un commentaire