Announcement

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

    JSON error message missing in API response

    After upgrading to SmartGWT 13, we no longer receive an error response via the API using JSON.

    This is verifiable in our software and in the latest built-in-ds.

    To make it easier to understand, I'll use the built-in-ds example.


    I have created the following class as a DMI, including the error return as specified in the Quickstart Guide, among other things:
    Code:
    package com.smartgwt.sample.server;
    
    import com.isomorphic.datasource.DSRequest;
    import com.isomorphic.datasource.DSResponse;
    
    public class AnimalsDMI {
    
    
        public DSResponse fetchAnimals(DSRequest dsRequest) throws Exception {
    
    
            if(dsRequest.getFieldValue("id") == null || dsRequest.getFieldValue("id").toString().equals("")) {
    
                DSResponse dsResponse = new DSResponse();
                dsResponse.setStatus(DSResponse.STATUS_VALIDATION_ERROR);
                dsResponse.addError("commonName", "Error, commonName-Field not set!");
                return dsResponse;
            }
    
            return dsRequest.execute();
    
        }
    }

    I have also extended animals.ds.xml as follows:
    Code:
    <operationBindings>
            <operationBinding operationType="fetch">
                <serverObject className="com.smartgwt.sample.server.AnimalsDMI" methodName="fetchAnimals"/>
            </operationBinding>
    </operationBindings>

    and finally adapted the web.xml and the RESTHandler servlet as follows:
    Code:
    <servlet>
            <servlet-name>RESTHandler</servlet-name>
            <servlet-class>com.isomorphic.servlet.RESTHandler</servlet-class>
            <init-param>
                <param-name>defaultDataFormat</param-name>
                <param-value>xml</param-value>
            </init-param>
            <init-param>
                <param-name>dynamicDataFormatParamName</param-name>
                <param-value>theDataFormat</param-value>
            </init-param>
            <init-param>
                <param-name>wrapJSONResponses</param-name>
                <param-value>false</param-value>
            </init-param>
    </servlet>

    My following query with XML:
    Code:
    curl --location 'http://127.0.0.1:8888/builtinds/sc/RESTHandler?theDataFormat=xml' \
    --header 'Content-Type: application/xml' \
    --header 'Cookie: isc_cState="ready"' \
    --data '<?xml version="1.0" encoding="UTF-8"?>
    <root>
       <data />
       <dataSource>animals</dataSource>
       <operationType>fetch</operationType>
    </root>'

    returns the following result:
    Code:
    <?xml version="1.0"?>
    <response>
        <queueStatus>-1</queueStatus>
        <status>-4</status>
        <errors>
            <commonName>
                <errorMessage>Error, commonName-Field not set!</errorMessage>
            </commonName>
        </errors>
        <data></data>
    </response>

    in JSON:
    Code:
    curl --location 'http://127.0.0.1:8888/builtinds/sc/RESTHandler?theDataFormat=json' \
    --header 'Content-Type: application/json' \
    --header 'Cookie: isc_cState="ready"' \
    --data '{
       "data":{
       },
       "dataSource":"animals",
       "operationType":"fetch",
       "operationId": "fetchAnimals"
    }'

    the error message is missing here, only the status was apparently adopted:
    Code:
    {
        "response": {
            "queueStatus": -1,
            "status": -4,
            "startRow": null,
            "endRow": null,
            "totalRows": null,
            "data": null
        }
    }

    We would be grateful for any help.

    #2
    Isomorphic Could you give us some feedback on this?
    We can of course provide further information if you need anything else.
    The topic is actually very relevant for us right now.

    Comment


      #3
      It has been assigned to be looked at. However, you didn't give your full version, which is always required. You should test with the latest patched build (see smartclient.com/builds) and let us know if you still see the problme.

      Comment


        #4
        I now tried it with the following versions:
        - SNAPSHOT_v13.1d_2024-07-08/PowerEdition Deployment (built 2024-07-08)
        - v13.0p_2024-07-07/PowerEdition Deployment (built 2024-07-07)
        - v13.0p_2024-04-03/PowerEdition Deployment (built 2024-04-03)

        The problem still occurs.

        Comment

        Working...
        X