I deal with the topic of REST Endpoint through Delivery API. I use YAML to get the result.
class: info.magnolia.rest.delivery.jcr.v2.JcrDeliveryEndpointDefinition
workspace: category
rootPath: /
includeSystemProperties: false
bypassWorkspaceAcls: true
depth: 3
nodeTypes:
- mgnl:folder
- mgnl:category
childNodeTypes:
- mgnl:category
- mgnl:contentNode
I have a question, is it possible to customize the response?? Now, If I enter http://localhost:8080/.rest/delivery/category/test_leer/@nodes , I have information about all nodes:
[
{
"@name": "test2",
"@path": "/test_leer/test2",
"@id": "31295828-16ec-4203-bb1d-a5f1ae95e14e",
"@nodeType": "mgnl:category",
"displayName": "test2",
"level": "level-1",
"relatedUUID": {
"@name": "relatedUUID",
"@path": "/test_leer/test2/relatedUUID",
"@id": "68724761-05ba-42eb-87ec-cb7ea38ea374",
"@nodeType": "mgnl:contentNode",
"@nodes": [
]
},
"test3": {
"@name": "test3",
"@path": "/test_leer/test2/test3",
"@id": "5bf54af6-8482-44e1-9514-7821098e721a",
"@nodeType": "mgnl:category",
"displayName": "test123",
"level": "level-1",
"relatedUUID": {
"@name": "relatedUUID",
"@path": "/test_leer/test2/test3/relatedUUID",
"@id": "c01bc7a7-e998-473b-84d5-1bbf799ad7b0",
"@nodeType": "mgnl:contentNode",
"relatedUUID0": {
"@name": "relatedUUID0",
"@path": "/test_leer/test2/test3/relatedUUID/relatedUUID0",
"@id": "095a85a4-3ccd-4186-b649-6757b65f4544",
"@nodeType": "mgnl:contentNode",
"relatedUUID": "31295828-16ec-4203-bb1d-a5f1ae95e14e",
"@nodes": [
]
},
"@nodes": [
"relatedUUID0"
]
},
"@nodes": [
"relatedUUID"
]
},
"@nodes": [
"relatedUUID",
"test3"
]
}
]
I have a question, is it possible to customize the response? For example, I need only @id,level, @nodeType and relatedUUID0 in a JSON-Response
The best way to control the output is to switch from Delivery API to GraphQL. That way you get full control.
The Delivery API doesn't provide functionality to print out only selected properties. You could somewhat achieve that by tweaking permissions of the user who executes the calls as the properties/subnodes user doesn't have permissions for would not be included in the output, but that's not really intended use of permissions. Using GraphQL gives you full control of the output instead.