Is there anyway to control the View of an object that gets returned after a Create or Update through the REST Services? My main object being returned is associated to another entity that has some very big text fields. I was surprised to see the large text fields being returned after ever UPDATE/CREATE.
There are no settings or request parameters that control the view of the returned JSON object. REST API response is the serialized entity that was returned by the DataManager. We’ll discuss and probably will provide an option not to return or limit the JSON for the create/update operations (https://youtrack.cuba-platform.com/issue/PL-10399) in future releases
In your project, you can override the EntitiesControllerManager bean and modify the JSON in the createEntity and updateEntity methods.
I’ve extended EntitiesControllerManager and overridden some classes and registered it as cuba_EntitiesControllerManager in the spring configuration file. I’ve done this in the web module. I’m getting an error now though: No qualifying bean of type ‘com.haulmont.restapi.common.RestControllerUtils’ available when spring is attempting to load my cuba_EntitiesControllerManager. I’m I overriding it in the wrong module?
Things are a little bit more complicated here. Let me explain. If you take a look at the web.xml file, you’ll find that requests to the /rest URLs are served by a separate dispatcher servlet:
This servlet uses a separate Spring context. Configuration files for the REST spring context are defined by the cuba.restSpringContextConfig application property. So you may do the following:
Override the controller manager class in the web module.
create new rest-web-spring.xml file with the overrriden bean defintiion in the web module
register the rest-web-spring.xml file in the web-app.properties file:
In a basic API request to the /entities/ path I’m now seeing a lot of extra fields not specified in the view that I’m sending as a paramenter:
{{baseUrl}}/entities/njuns$Ticket/:entityId?view=ticket-api-view
Hi Josh,
Next time please create a separate topic for the new problem. Can you please provide more information: how does your view looks like and what extra fields are returned in the response?
No qualifying bean of type 'com.haulmont.restapi.service.EntitiesControllerManager' available: expected at least 1 bean which qualifies as autowire candidate.