Announcement

Collapse
No announcement yet.

Not able to update date time field as empty or null using REST api

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Not able to update date time field as empty or null using REST api

    Hi,

    I'm trying to clear/reset a Customer custom field of type date time field that is already populated. I'm trying to do it setting the field as "" (empty) but I'm getting the following error in the logs.

    [2021-09-08 16:21:07] Espo.ERROR: (22007) SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '' for column `espo_db`.`contact`.`message_sent_time` at row 1; PUT /Contact/6111659c86550ed53; line: 72, file: application/Espo/ORM/SqlExecutor.php [] []

    Obviously this error makes sense but my question is... how I can clear or reset a date time field using the REST api through an update (PUT request)? I'm aware that this approach of sending empty values works for strings or number fields, but for date time is not working.

    My request:

    url -> api/v1/Contact/6111659c86550ed53
    Payload:
    {
    "messageSentTime": ""
    }

    Thank you in advance

  • #2
    I fixed it just sending the value as null.

    url -> api/v1/Contact/6111659c86550ed53
    Payload:
    {
    "messageSentTime": null
    }

    SOLVED.

    Comment

    Working...
    X