问题:
POST /LAPI/V1.0/PACS/Controller/HeartReportInfo HTTP/1.1
Content-Type: application/json
Content-Length: 180
{
"RefId": "3d519d30-af08-4654-919f-3488a9ef9b68",
"Time": "2020-05-26 16:08:54",
"NextTime": "2020-05-26 16:09:24",
"DeviceCode": "13110201011197001001",
"DeviceType": 5
}
这是设备发送的整个请求的内容,我写了一个对应的接口去接收,完全接收不到, 用postman测试我的接口,没有问题.
接口用.net core 写的
[Route("LAPI/V1.0/PACS/[controller]/[action]")]
[ApiController]
public class ControllerController : ControllerBase
{
[HttpGet]
[HttpPost]
public string HeartReportInfo()
{
StreamReader sr = new StreamReader(Request.Body);
Task<string> task = sr.ReadToEndAsync();
if(task.Result!=null)
{
Console.WriteLine(task.Result);
}
else
{
Console.WriteLine("数据为空");
}
return "ok";
}
}
回答1:
设备发送到HTTP中的host头部呢?是你调试的进程的IP和端口吗?
回答2:
public string HeartReportInfo([FromBody] dynamic Postdata)
{
string Id = Postdata["Id"];获取Id
}
把Id改成你传的参数,core接受body里面的值是要加FromBody
回答3:
这是java写的netty....