Read/Write Date custom field

Wanted to share since I hadn’t seen this anywhere yet. For the new Date custom field type, when reading a date value via the API you receive
“date_value”: {
“date”: “2022-08-18”,
“date_time”: null
}
For a date. If the value was a datetime, then you would have “date”:null and “date_time” would have an appropriate value.

When updating a custom field in a task, instead of simply specifying the value for the field as “2022-08-18” like you might for a text field, you have to pass an object with either (but not both) a “date” key or a “date_time” key. These dates then follow the same formatting as due_on and due_at.

So to update a date custom field, the call would look something like:
“custom_fields”: {
“4578152156”: {“date”:“2022-08-18”}
},

I didn’t see this in the API docs yet and I didn’t find it when trying to search the forums.

If you use the wrong format, the API returns an error saying your object isn’t formatted correctly or that it was expecting an object, but it took a little trial and error to get it right. Hope this helps someone else.

4 Likes

Just ran into this issue, thank you so much!

1 Like

Excellent post, @Anthony_Tamalonis, thank you! I discovered this a week or two ago and should have posted here but didn’t - but you did the right thing! :clap:

1 Like

Thanks for sharing!

1 Like

Thanks for pointing this out. I think the API documentation should have a place where we can request updates to the documentation…

2 Likes

This is always done through forum posts :slight_smile:

1 Like