JSON payload for HttpClient in C#?

Moraeterway

New Member
How to pass in a JSON payload for consuming a REST service.Here is what I am trying:\[code\]var requestUrl = "http://example.org";using (var client = new HttpClient()){ client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualifiedHeaderValue("application/json")); var result = client.Post(requestUrl); var content = result.Content.ReadAsString(); dynamic value = http://stackoverflow.com/questions/8199675/JsonValue.Parse(content); string msg = String.Format("{0} {1}", value.SomeTest, value.AnotherTest); return msg;}\[/code\]How do I pass something like this as a parameter to the request?:\[code\]{"SomeProp1":"abc","AnotherProp1":"123","NextProp2":"zyx"}\[/code\]
 
Top