Chris
Chris

Reputation: 12282

Web API null parameter value in POST action

I'm trying to use angular and asp.net vNext Web API. I have a controller up but when using angular's $resource the object values are not resolved (Post method parameter is null)

The request itself has nothing out of the ordinary, though it does send json back. I think I've seen somewhere that vNext doesn't support content negotiation yet so maybe that's it. Can anyone confirm or shed some light on the subject?

Also - is there a way to get to the raw post data in Web API? (I'm using the core framework) cause the Request.Form that I know from mvc is not there any more. I tried the GetFormAsync but that returns an empty collection.

EDIT: Confirmed that the reason for not binding the parameter is the fact that data is sent as JSON. When form encoding is used, the parameter values are resolved correctly.

Upvotes: 1

Views: 331

Answers (1)

Chris
Chris

Reputation: 12282

using [FromBody] attribute on the param solved the issue.

Upvotes: 1

Related Questions