DEVCON 2026    |    2-5 November 2026 – QEII Centre – London, UK    |    Register now! 

Blogs

Nesting Liferay JSON Service calls

Allen Ziegenfus
Allen Ziegenfus
Lectura de menos de un minuto

One really cool feature of Liferay JSON web services is the ability to nest service calls.

For example, what if you would like to update a web content journal article via JSON? The /journalarticle/update-article method requires the following four parameters: 

 

Parameter Description
groupId ID for the Liferay site
articleId ID for the web content journal article
content XML representation of the web content
version Article version number

groupId, articleId, and content are easy to come up with. But how can I find the article version number? I could make a separate call to get-article to retrieve the article metadata including the version number, but this would add extra complexity (and an extra network call) to my client code. 

Instead it is also possible to automatically look up the version number while updating with a nested call like this: 

 var cmd = {
            "$article = /journalarticle/get-article": {
                "groupId": article.groupId,
                "articleId": article.articleId,
                "$update = /journalarticle/update-article": {
                    "@version": "$article.version",
                    "groupId": article.groupId,
                    "articleId": article.articleId,
                    "content": xml,
                    "serviceContext.scopeGroupId": article.groupId
                }
            }
        };

How cool!

Comentarios de la página
Thank you for your article, it's a usefull feature not known by most users.

For those who seek more, there are some examples in the official tutorial : https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/json-web-services-invoker#nesting-service-calls

Related Assets...

No se encontraron resultados

More Blog Entries...

Ben Turner
septiembre 02, 2026
David H Nebinger
agosto 18, 2026
David H Nebinger
agosto 16, 2026