【问题标题】:Postman returns 204 no content error to post requestPostman 向 post 请求返回 204 no content 错误
【发布时间】:2017-07-24 20:01:49
【问题描述】:

我的请求正文: { “作者”:“丹布朗”, "title":"达芬奇密码" }。 我正在向http://localhost:49497/api/values 发送请求。 它返回 204 错误。这个问题的原因是什么?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace APIlab2.Controllers
{
    public class TestObject
    {
        public string author{ get; set; }
        public string title { get; set; }
    }
    public class ValuesController : ApiController
    {
        // GET api/values
        List<TestObject> list = new List<TestObject>();
        public IEnumerable<TestObject> Get()
        {
            return list;
        }

        // GET api/values/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/values
        public void Post([FromBody]TestObject obj)
        {
            list.Add(obj);
        }

        // PUT api/values/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
        }
    }
}

【问题讨论】:

    标签: asp.net post postman


    【解决方案1】:

    204 不是错误。您没有从服务器返回任何内容。只需将其添加到列表中。因此不返回任何内容

    【讨论】:

      【解决方案2】:

      这是 Postman 中的一个已知错误。

      https://github.com/postmanlabs/postman-app-support/issues/2418

      【讨论】:

        猜你喜欢
        • 2021-11-09
        • 2020-12-31
        • 1970-01-01
        • 2018-07-11
        • 1970-01-01
        • 1970-01-01
        • 2015-06-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多