Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should the Request Body look like?

I have a WCF service with a method which looks like this (returns null for testing with the debugger, I care only about getting data in for now):

[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "fares", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public List<Fare> GetFares(Dictionary<int, int> itineraries, decimal? threshold, bool includeInternational)
{
    return null;
}

I am trying to make a request to that method using Fiddler, but can't get my head around on what the correct Request Body should be. I could change the Dictionary parameter to something else if that works better.

In Request Headers I pass:

User-Agent: Fiddler
Content-Type: application/json; charset=utf-8

What should I put in the body?

like image 534
Pawel Krakowiak Avatar asked Mar 17 '09 11:03

Pawel Krakowiak


1 Answers

I think this is what you are after.

{
"itineraries" : [{"Key":1,"Value":2},{"Key":2,"Value":3}],
"threshold" : 1.0,
"includeInternational" : true
}

The dictionary serializes as a Key Value array.

like image 145
Matthew Pelser Avatar answered Oct 07 '22 14:10

Matthew Pelser