DayAndDateTime is not a JSON object

I’m trying to use Update a task to update a d```ate_value custom field in an Asana task. The date field is special, in that it consists of 2 values when the task is obtained via GET:

"date_value": {
          "date": "2023-09-11",
          "date_time": null

I’ve tried using the same when updating the task (PUT request: Update a task), but I always get a date_value: DayAndDateTime is not a JSON object error.

The docs on date custom fields (Custom fields) are not clear in how date values need to be formatted, and how a date value should be entered in the CUSTOM_FIELDS OBJECT at Update a task (see attached).

Screenshot 2023-09-11 at 9.49.25 AM

In other words, what string to do I use in the CUSTOM_FIELDS OBJECT section of Update a task to update a date value in a task?

I’ve tried:

  • 2023-09-18
  • 2023-09-18T00:00:00.000
  • { “date”: “2023-09-18” }
  • { “date”: “2023-09-18”, “date_time”: null }

All result in the following error: "date_value: DayAndDateTime is not a JSON object:

Hi @Nick_Youngblut,

Here is the correct format:

“custom_fields”: {
“123456789”: {“date”:“2022-08-18”}

where “123456789” is the gid of the date custom field.

If your value contains a time component, then it would be

“custom_fields”: {
“123456789”: {“date_time”:“2022-08-18T09:20:32.000Z”}
1 Like

Thanks @Phil_Seeman!
Maybe it would be useful to provide that info in the docs on custom fields? … and/or in the API docs?

I agree! Pinging Asana here: @John_Vu @AndrewWong

Thanks @Phil_Seeman for helping @Nick_Youngblut out.

I have gone ahead and sent a PR to update our custom field update descriptions.

"{custom_field_gid}" => Value (Can be text, number, etc.)

"{custom_field_gid}" => Value (Can be text, number, etc.). For date use format "YYYY-MM-DD" (EX: 2019-09-15). For date-time use ISO 8601 date string in UTC (EX: 2019-09-15T02:06:58.147Z)

@Nick_Youngblut Hope this makes it more clear. If you would like us to re-word it let us know.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.