Legacy Knowledge Base
Published Jun. 30, 2025

Invalid date error when creating content with date field using APIs

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

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

  • When using the Liferay API to create Web Content with a date field, using the "dd-MM-yyyy'T'HH:mm:ss'Z'" format results in the display of an "Invalid date" error.

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

Resolution

  • To solve the "Invalid date" error, we should format the date field as "dd-MM-yyyy" without including the time. This will ensure that the date is recognized as a valid date and can be used in the Web Content.

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"

Additional Information

 

Did this article resolve your issue ?

Legacy Knowledge Base