WebAPI parameters passed after message are null

I am testing using WebAPI 2 and I have created the following controller method.

// POST api/values
public string Post([FromBody] string value)
{
    string returnValue = "Return: " + value ;
    return returnValue;
}

When I send the following message with fiddler, the method parameter returns null.

POST http://localhost:50814/api/Values/ HTTP/1.1
Host: localhost:50814
Content-Type: application/json
Content-Length: 14

{value: "New"}

I just used my code as much as I can, but still it remains zero.

I think I'm missing something very simple, but I have no ideas. Can someone please help me?

Thanks Sander

+4
source share
1 answer

If you take a simple line from your Mail method, try sending only this:

POST http://localhost:50814/api/Values/ HTTP/1.1
Host: localhost:50814
Content-Type: application/json
Content-Length: 10

"MyString"
+3
source

Source: https://habr.com/ru/post/1527389/


All Articles