Reputation: 449
I'm testing with 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'm posting the following message with fiddler the method parameter keep returning null.
POST http://localhost:50814/api/Values/ HTTP/1.1
Host: localhost:50814
Content-Type: application/json
Content-Length: 14
{value: "New"}
I have simplyfied my code already as much as i can but still it stays null.
I think I'm overlooking something very simple but i'm out of ideas. Could someone please help me?
Thanks Sander
Upvotes: 4
Views: 2665
Reputation: 5375
If you're taking a simple String from your Controller's Post method, try sending just this:
POST http://localhost:50814/api/Values/ HTTP/1.1
Host: localhost:50814
Content-Type: application/json
Content-Length: 10
"MyString"
Upvotes: 3