Reputation: 13
My request's body: { "author":"Dan Brown", "title":"Da Vinci's code" }. And I am sending request to http://localhost:49497/api/values. It is returning 204 error.What can be the reason of this problem?
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)
{
}
}
}
Upvotes: 1
Views: 19654
Reputation: 723
This is a known bug in Postman.
https://github.com/postmanlabs/postman-app-support/issues/2418
Upvotes: 0
Reputation: 688
204 is not an error. You are not returning anything from the server. Just adding it to the list. Hence no content is returned
Upvotes: 2