Reputation: 857
The json values are blank when calling this code from the API:
[Route("api/[controller]")]
public class ReportDesignerSetupController : ControllerBase
{
[HttpPost("[action]")]
public object GetReportDesignerModel([FromForm] string reportUrl)
{
return Ok(new JavaScriptSerializer().Deserialize<object>("{name: \"Seb\", age: 42, gender: \"M\"}"));
}
}
{
"name": [],
"age": [],
"gender": []
}
Does anybody has any reason the value are blanks?
Thank you very much!
Reference:
I am debugging a project related to DevEXpress.
Upvotes: 0
Views: 73
Reputation: 3460
Try to use Newtonsoft.Json if you can. Just tried this code locally and it works just fine
[HttpGet("test")]
public IActionResult GetReportDesignerModel([FromForm] string reportUrl)
{
return Ok(JsonConvert.DeserializeObject("{name: \"Seb\", age: 42, gender: \"M\"}"));
}
From Postman
Upvotes: 1
Reputation: 156
How do you call your web api(url) from postman/insomnia .. etc ? It seems you are returning a data(GET) but your method is marked as [HttpPost("[action]")]
. Could you edit the method as HttpGet
and try?
Upvotes: 0