legacy-knowledge-base
公開されました Jun. 30, 2025

APIを使用して日付フィールドを持つコンテンツを作成する際に、無効な日付のエラーが発生する。

written-by

Jamilly Macedo

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

問題

  • Liferay APIを使用して日付フィールドを持つWebコンテンツを作成する場合、 "dd-MM-yyyy'T'HH:mm:ss'Z'" 形式を使用すると、「Invalid date」エラーが表示されます。

curl \
-H "Content-Type: application/json" \
-H 'Accept-Language: en-US' \
-X POST \
"http://localhost:8080/o/headless-delivery/v1.0/sites/${1}/structured-contents" \
-d "{\"contentFields\": [{\"contentFieldValue\": {\"data\": \"2023-04-20T00:00:00Z\"}, \"name\": \"Date91701211\"}], \"contentStructureId\": \"${2}\", \"title\": \"Test Article 1\"}" \
-u "test@liferay.com:test"

Environment

  • Liferay DXP 7.4

解決策

  • Invalid date "エラーを解決するには、日付フィールドを "dd-MM-yyyy" のように、時刻を含めずにフォーマットする必要があります。 これにより、日付が有効な日付として認識され、Webコンテンツで使用することができるようになります。

curl \
-H "Content-Type: application/json" \
-H 'Accept-Language: en-US' \
-X POST \
"http://localhost:8080/o/headless-delivery/v1.0/sites/${1}/structured-contents" \
-d "{\"contentFields\": [{\"contentFieldValue\": {\"data\": \"2023-04-20\"}, \"name\": \"Date91701211\"}], \"contentStructureId\": \"${2}\", \"title\": \"Test Article 2\"}" \
-u "test@liferay.com:test"

追加情報

did-this-article-resolve-your-issue

legacy-knowledge-base