.net开发postAPI,接收到的数据值都为空

Model

namespace VSProjects.Models
{
    public class QueryRequest
    {
        public string id;
        public string name;
        public string duty;
        public string date1;
        public string date2;
    }

    public class QueryResponse
    {
        public string id;
        public string name;
        public string duty;
        public string date1;
        public string date2;
        public string time;
    }
}

WeatherForecastController

using System;

using Microsoft.AspNetCore.Mvc;

using VSProjects.Models;

namespace VSProjects.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class WeatherForecastController : ControllerBase
    {
        //POST: api/weatherforecast
        [HttpPost]
        public QueryResponse Post([FromBody] QueryRequest req)
        {
            QueryResponse resp = new QueryResponse();
            try
            {

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }


            return resp;
        }

    }
}

我在try里面打了断点,postman测试接口可以进入断点,但是req拿到的数据都是null,为什么呢?

可能是postman请求错误,postman有多种post请求方式图片说明

可以按照图片方式试试

要用form-data模式请求,raw是json格式,你可以试试