Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 从API返回的值为空_Asp.net_.net Core - Fatal编程技术网

Asp.net 从API返回的值为空

Asp.net 从API返回的值为空,asp.net,.net-core,Asp.net,.net Core,从API调用此代码时,json值为空: [Route("api/[controller]")] public class ReportDesignerSetupController : ControllerBase { [HttpPost("[action]")] public object GetReportDesignerModel([FromForm] string reportUrl)

从API调用此代码时,json值为空:

    [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\"}"));
        }
    }

有人有任何理由认为该值为空吗

多谢各位

参考:

我正在调试与DevEXpress相关的项目


如何从邮递员/管理员那里调用web api(url)。。等您似乎正在返回数据(GET),但您的方法被标记为
[HttpPost(“[action]”)
。您可以将该方法编辑为
HttpGet
并尝试吗?

如果可以,请尝试使用Newtonsoft.Json。 只是在本地尝试了这段代码,效果很好

    [HttpGet("test")]
    public IActionResult GetReportDesignerModel([FromForm] string reportUrl)
    {
        return Ok(JsonConvert.DeserializeObject("{name: \"Seb\", age: 42, gender: \"M\"}"));
    }
邮递员


使用失眠,与post或get一样,感谢您的建议。Adding.AddNewtonsoftJson()修复此问题。谢谢
    [HttpGet("test")]
    public IActionResult GetReportDesignerModel([FromForm] string reportUrl)
    {
        return Ok(JsonConvert.DeserializeObject("{name: \"Seb\", age: 42, gender: \"M\"}"));
    }