I am using SmartGWT 2.2.
I have a server side REST resource that accepts a GET request. No parameters or body are needed for this particular resource.
The resource can return XML or JSON, depending on the "Accept" header provided in the request.
For the life of me, I cannot seem to set up the Operation Binding to result in the request to have a "Accept" header of "application/json". I've tried using both RestDataSource as well as the base DataSource.
The operation binding looks like this:
I then read somewhere in the javadoc that the "setDataFormat" just prepares the datasource for what to expect back, as opposed to actually preparing the request to specify the data format. So I then tried explicitly setting the header in the request object:
Regardless of the above, looking at the GET trace in firebug shows this as the "Accept" header:
Any help would be appreciated. Thanks!
Alex
I have a server side REST resource that accepts a GET request. No parameters or body are needed for this particular resource.
The resource can return XML or JSON, depending on the "Accept" header provided in the request.
For the life of me, I cannot seem to set up the Operation Binding to result in the request to have a "Accept" header of "application/json". I've tried using both RestDataSource as well as the base DataSource.
The operation binding looks like this:
Code:
OperationBinding fetch = new OperationBinding(DSOperationType.FETCH, "/my/get/based/resource"); fetch.setDataProtocol(DSProtocol.GETPARAMS); fetch.setDataFormat(DSDataFormat.JSON); // my datasource created earlier ds.setOperationBindings(fetch);
Code:
DSRequest request = new DSRequest(); request.setOperationType(DSOperationType.FETCH); Map<String, String> headers = new HashMap<String, String>(); headers.put("Accept", "application/json"); request.setHeaderData(headers); fetch.setRequestProperties(request);
Code:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.
Alex
Comment