The parameter is not coming through. I have tried to use the [FromBody] parameter but it does not make any difference. I know my code works as I have used it in previous versions of umbraco.
It works if i use GET but it posts in the query string and i'm sending alot of data so this is not an option.
Update: I changed the type to Dynamic, and am receiving the object wrapped in two {{ tags. I try to use JsonConvert.SerializeObject to convert it to its type but get an exception "BasicAuthenticationMiddleware.cs not found"
Cant post parameter to API Controller
I am trying to post an object to an API Endpoint.
The parameter is not coming through. I have tried to use the [FromBody] parameter but it does not make any difference. I know my code works as I have used it in previous versions of umbraco.
It works if i use GET but it posts in the query string and i'm sending alot of data so this is not an option.
Update: I changed the type to Dynamic, and am receiving the object wrapped in two {{ tags. I try to use JsonConvert.SerializeObject to convert it to its type but get an exception "BasicAuthenticationMiddleware.cs not found"
Any help would be much appreciated.
Hi!
Try wrapping your parameter in an object, e.g
FileDetailRequest
or similar and taking that as a parameter instead.when you read data from body in your controller, you need object like
Then model builder from asp.net can map you request. You neet only cange method in your controller like this.
The issue was how i was stringifying the object. i used JSON.stringify({ test: "blah" }) but should of just been JSON.stringify({ "blah" }).
Makes sense but was working the way i first done it on older versions of umbraco/.net
is working on a reply...