Given the following code and config for OpenRasta :
ResourceSpace.Has.ResourcesOfType<Foo>()
.AtUri("/foo/{fooID}")
.And.AtUri("/foo")
.HandledBy<FooHandler>()
.AsJsonDataContract();
public OperationResult GetFoo(int fooID) { }
public OperationResult PostFoo(Foo foo) { }
public class Foo
{
public int ID { get; set; }
public string Name { get; set; }
}
What is the correct format for the body of the request if I want to post to the PostFoo method on my FooHandler. Can it be json (i.e. the same format I would recieve from GetFoo) or should it be name-value pairs (e.g. ID=1&Name=FooManChu) ?
Do I need to set any additional headers in the post request such as content type ?
I am trying to get this working bu开发者_如何学Ct I seem to be getting 415 errors when I try to do this ?
If you send a Content-Type of application/json, that'll work. If you want to use key value pairs, using either multipart/form-data or application/x-www-form-urlencoded then that'll work too.
If you don't specify Content-Type, it defaults to application/octet-stream, for which you only have a mapping to Stream (and byte[]).
精彩评论