Feb 09, 2010, 8:12 AM
FormPanel and "Bad request" errors
I have the following Coolite controls and markup in my APSX page - I've left out the entire page markup as it's not relevant.
The page's purpose is to call a remote service method which returns a JSON-serialized object back to the page - this is achieved by the ExtJS call in the DocumentReady handler as below.
From examining the request header, I can see that the content-type is application/x-www-form-urlencoded; charset=UTF-8 whereas it should be application/json.
My question is, how do I set up the request so that it's sent as JSON and not RAW?
The page's purpose is to call a remote service method which returns a JSON-serialized object back to the page - this is achieved by the ExtJS call in the DocumentReady handler as below.
<ext:ScriptManagerProxy runat="server" ID="ScriptManagerProxyMain">
<Listeners>
<DocumentReady Handler="if (globalPersonId) {
var request = {};
request.personId = globalPersonId;
alert('Request='+Ext.util.JSON.encode(request));
#{PersonForm}.load({params: Ext.util.JSON.encode(request)});
}
" />
</Listeners>
</ext:ScriptManagerProxy>
.
.
.
<ext:FormPanel
ID="PersonForm" runat="server" Title="Candidate details"
BodyStyle="padding:5px;"
Method="POST"
AutoWidth="true"
AutoScroll="true"
Border="false"
Url="~/Services/PersonService.svc/AjaxEndpoint/GetPerson"
>
.
.
.
.
</ext:FormPanel>
The problem is, when I snoop the HTTP traffic between client and server, the call to load the form causes the following ASP.NET error - The server encountered an error processing the request. The exception message is 'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'.From examining the request header, I can see that the content-type is application/x-www-form-urlencoded; charset=UTF-8 whereas it should be application/json.
My question is, how do I set up the request so that it's sent as JSON and not RAW?