HttpRequestMessage and HTML/ASP.Net form

Topics: Web Api
Aug 6, 2011 at 9:33 PM

Hi,

In the QueryableSample project, use HttpRequestMessage is illustrated to post to an API url.

The example

request.Content = new ObjectContent<Contact>(contact, "application/xml");
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
var response = client.Send(request);

uses a ObjectContent class as a Content for HttpRequestMessage . I assume this is XML message that is posted to URL.

Is there any way to post a HTML/ASP,Net form as a JSON payload using HttpRequestMessage ?

Thanks,

Mahesh.

  

Sep 27, 2011 at 11:07 PM
Edited Sep 27, 2011 at 11:07 PM

Did you ever figure out how to post in json, instead of xml?

Coordinator
Sep 28, 2011 at 4:44 AM

Did you try simply replacing “application/xml” with “application/json” in the above code?

Daniel Roth

From: terrence77 [email removed]
Sent: Tuesday, September 27, 2011 3:08 PM
To: Daniel Roth
Subject: Re: HttpRequestMessage and HTML/ASP.Net form [wcf:268057]

From: terrence77

Did you ever figure out how to post in json, instead of xml?

Sep 29, 2011 at 3:23 PM

Daniel, I am having trouble using application/x-www-form-urlencoded.  I was wondering if he was having the same problem that I was, meaning everything is being sent via xml no matter what application you specify.