legacy-knowledge-base
公開されました Sep. 10, 2025

Site-initializer using PATCH instead of PUT for object definition with API

written-by

Ahmed Abdin

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

learn-legacy-article-disclaimer-text

Issue

  • I am having issues updating our object definitions via site initializer synchronization. The issue was first observed with new fields not getting added to objects. When I do a manual object definition export/add fields/import, it works, and I get the new fields; if I try it via site initializer, no fields get added.

Reproduction Steps:

1. Start 2025.q1.2-lts
2. Go to Control Panel --> Object --> Objects, and create an object (for example: ODLiferayTest1)
3. On its Field tab, add a field (OFLiferayText1)
4. Execute the attached CURL request with the provided JSON (I tested with Postman). Do not forget to replace the object ID with yours here: http://localhost:8080/o/object-admin/v1.0/object-definitions/57717

and the ERC with yours: "externalReferenceCode": "94dc9456-ce93-025c-84ea-be142a5c9b37",

curl -X 'PATCH' \
  'http://localhost:8080/o/object-admin/v1.0/object-definitions/57717' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'x-csrf-token: 7xrI0KOQ' \
  -d '{
    "label": {
        "en_US": "ODLiferayTest1_PATCHED"
    },
    "pluralLabel": {
        "en_US": "ODLiferayTest1s_PATCHED"
    },
    "objectFields": [
        {
            "label": {
                "en_US": "OFLiferayText1_PATCHED"
            },
            "externalReferenceCode": "94dc9456-ce93-025c-84ea-be142a5c9b37",
            "name": "oFLiferayText1"
        },
        {
          "DBType": "String",
          "indexed": true,
          "indexedAsKeyword": false,
          "label": {
            "en_US": "OFLiferayCode"
          },
          "name": "oFLiferayCode",
          "type": "String",
          "required": true,
          "externalReferenceCode": "obj-code"
        }
    ]
}'

Expected Result: The label and pluralLabel of the Object Definition are updated.
The label of the existing field (OFLiferayText1) is updated.
A new field (OFLiferayCode) is added.

Actual Result: The label and pluralLabel of the Object Definition are updated.
The Object Fields remain unchanged (no updates to OFLiferayText1, and OFLiferayCode is not added).

Environment

  • Quarterly Release 2025.q1.2-lts

Resolution

  • The current behavior is expected. Calling a patch to update nested structures (like object fields) is currently a product limitation. The Product Team is currently evaluating the case.
  • A workaround to avoid this issue is to modify the nested structures or create new ones, we suggest creating the object-fields directory and placing the new fields there. Please see this example.
did-this-article-resolve-your-issue

legacy-knowledge-base