Given a new Asp.Net MVC 4 Web Api application, which has the method
public class ValuesController : ApiController
{
// PUT api/values/5
public void Put(int id, [FromBody]string value)
{
lastval = "b " + value;
}
}
How do we call this method via httpie? I tried
http PUT localhost:20780/api/values/3 value="test"
which calls the web api method passing the correct id 3, but the value “test” does not arrive, it is null in the call.
Does the controller expect form-encoded data? If yes, then you need to use the
--form, -foption. It’s because HTTPie sends JSON by default: