Reputation: 31
I want an angular application to send any JSON data to a .Net Core WebAPI controller.
I don't want to have a pre-defined model accepting the JSON in the controller function.
I don't know how to accept it. Kindly help. In Angular, the data is JSON.stringified
and POSTED
Here is my angular TS code that sends the JSON:
Controller that can accept any form of JSON:
Upvotes: 1
Views: 2852
Reputation: 2474
As long as the client is posting JSON, you can define a string
parameter that will accept any format JSON data.
For example:
[HttpPost] public async Task<IActionResult> UploadJson([FromBody] string json) { return Ok(); }
Upvotes: 1