Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    RestDataSource not populating grid properly

    Hi Isomorphic,
    I want to consume a third party rest service using RestDataSource.

    e.g. I have a sample rest service http://localhost:8080//accountsInfo , returned json is : {"balance":1000,"type":"savings"}

    Below is my code to consume this:


    RestDataSource countryDS = new RestDataSource() {
    @Override
    protected Object transformRequest(DSRequest dsRequest) {
    return super.transformRequest(dsRequest);
    }

    @Override
    protected void transformResponse(DSResponse response, DSRequest request, Object data) {
    super.transformResponse(response, request, data);
    }
    };
    OperationBinding fetch = new OperationBinding();
    fetch.setOperationType(DSOperationType.FETCH);
    fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
    fetch.setDataFormat(DSDataFormat.JSON);

    countryDS.setFetchDataURL("http://localhost:8080//accountsInfo");
    countryDS.setJsonPrefix("");
    countryDS.setJsonSuffix("");
    countryDS.setDataFormat(DSDataFormat.JSON);
    countryDS.setUseStrictJSON(false);

    DataSourceTextField balance = new DataSourceTextField("balance", "balance");
    DataSourceTextField type = new DataSourceTextField("type", "type");
    countryDS.setFields(balance, type);

    ListGridField codeField = new ListGridField("balance");
    ListGridField nameField = new ListGridField("type");
    grid.setDataSource(countryDS);
    grid.setFields(codeField, nameField);
    grid.setAutoFetchData(true);


    Attached is the screenshot of console.


    My grid doesn't get loaded with data. On browser console i get warning:

    ISC_Core.js:1197 *21:23:33.379:XRP4:WARN:RestDataSource:isc_HomeTabView_1_0:RestDataSouce transformResponse(): JSON response text does not appear to be in standard response format.

    Please suggest?
    Attached Files

    #2
    The error message is correct, the JSON you are trying to consume looks nothing like the standard response format for RestDataSourcd. As the docs tell you, if you are adapting to a pre-existing service, use DataSource, not RestDataSource.

    Please also revisit the QuickStart Guide, Data Integration chapter.

    Comment

    Working...
    X