jqGrid communicates with the server using query parameters (GET) and form parameters (PUT / POST). Is it possible to submit a json message instead? For example, instead of submitting myQuery?rows=10&page=1&country=spain, can we submit this HTTP payload to the server: {"rows":"10", "page":"1", "country": "spain"? THis functionality would be needed if we want to interact with a RESTful web service that expects a pre-defined message structure. On the other hand, GET requests don't have a body, so I'm wondering if passing a json message to a GET RESTful service is even possible? I am designing both sides of the service (jqGrid + CXF). My concern is about exposing a clear contract for my service, as opposed to just accepting an undescribed Map of parameters. I will appreciate feedback on how this could be achieved with jqGrid.
Asked
Active
Viewed 328 times
1 Answers
0
You can use serializeGridData
callback to convert the posted parameters to one JSON string. For example
serializeGridData: function (postData) {
return JSON.stringify(postData);
}
The answer describes more options which you could need for communication with RESTful service.
If we speak about RESTful services, then it's important to mention that parameters like rows
, page
, sidx
and sord
are not a subject of classical RESTful URL because the parts are not a resource. So the usage of parameters of URL ("?param1=value1¶m2=value2&...") would be absolutely complaint to RESTful service. OData uses (see here for example) the information about paging also as parameters. The answer provide an example of accessing RESTful Open Data Protocol (OData) services of Windows Azure Mobile Services.