Legacy Knowledge Base
Published Sep. 10, 2025

How to get the groups associated to organizations using JSON Web Services

Written By

Ricardo Couso

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • There is no method available in the JSON Web Services API to obtain the groups (i.e. sites) associated to organizations. Is there a way to get them?

Environment

  • Liferay DXP 7.0, 7.1, 7.2, 7.3

Resolution

  • There are two auxiliary methods available in the JSON WS API than can be combined to get the desired result:
    • /organization/get-organizations: 
      • Input: companyId, parentOrganizationId
      • Output: [Organization]
    • /group/get-organizations-groups
      • Input: [Organization]
      • Output: [Group]
  • The complex objects Organization and Group are represented as JSON objects.
  • These two methods are composable: the output of /organization/get-organizations can be used, without modification, as the input of /group/get-organizations-groups.
  • An example:
    1. The first method /organization/get-organizations can be called with the command:
      curl http://localhost:8080/api/jsonws/organization/get-organizations \
      -u test@liferay.com:test \
      -d companyId=20101 \
      -d parentOrganizationId=0
      where we have chosen a particular Liferay instance with companyId=20101, and no restriction on the organizations with parentOrganizationId=0.
    2. The output is a JSON list:
      [
      {
      [...], "companyId": "20101", [...], "organizationId": "41003", "parentOrganizationId": "0", [...]
      },
      {
      [...], "companyId": "20101", [...], "organizationId": "41008", "parentOrganizationId": "0", [...]
      }
      ]
    3. This output can be escaped and used as input in the second method /group/get-organizations-groups:
      curl http://localhost:9090/api/jsonws/group/get-organizations-groups \
      -u test@liferay.com:test \
      -d organizations=%5B%0A%20%20%7B%0A%20%20%20%20%22comments%22[...]%20%7D%0A%5D
    4. The output is another JSON list with the desired groups:
      [
      {
      [...], "groupId": "41005", "groupKey": "org01 LFR_ORGANIZATION", [...]
      },
      {
      [...], "groupId": "41010", "groupKey": "org02 LFR_ORGANIZATION", [...]
      }
      ]
Did this article resolve your issue ?

Legacy Knowledge Base