[PYTHON API] Adding an new row with date column

tomlinsa
tomlinsa
edited 12/09/19 in API & Developers

Using the python SDK, I'm having trouble adding a new row to a sheet where one of the columns is a DATE column. For ex, doing:

cell.value = datetime.datetime.now()

with the column type as DATE doesn't assign anything to the column, and the request comes back with an error since the cell.value is empty.

If online I switch the column type to TEXT NUMBER and do:

cell.value = str(datetime.datetime.now())

then it completes successfully. I'm not sure what I'm doing wrong. Looking into the source of the python sdk seems to indicate that a datetime.datetime object is what should be passed, but when stepping through the code, it does some type checking and skips it setter since it's not realizing at the time that the cell is from a DATE column. Any help would be appreciated.

Comments

  • dave-inden
    dave-inden ✭✭✭

    Have you tried adding the row with the value attribute on the cell object set to a string of the date in the ISO-8601 format the API is expecting? This would be used if sending the request directly via a REST client or something like cURL. For example, if sending today's date of Oct 13th, 2019 you would put I "2019-10-13" as the value.