Failing to post date value to Summary field

I am working with the python sdk, and I cannot figure out how to post a date value.

Here is a picture of what I am doing. where sum is a dictionary of posting data

If I am trying to post a formula, I check that my "Posting value" has a equal sign, and then the formula goes there, and it posts fine.

If I am trying to post a direct value (in this case a date), I have not been successful posting.

There are two fields, object_value and display_value, and neither work for posting. The way the data naturally sits if I do a get request is:

but when I try to post a displayValue :{'objectValue: "DATE", 'value': "12/12/99"}, I get the following error--

Any idea what format to use to post dates in the python SDK? if not I'll have to use the requests library and see if I can find the format from the Curl command

Answers

  • Hey @ArielDB

    The Smartsheet API needs dates to be formatted in ISO-8601 format: YYYY-MM-DDTHH:MM:SSZ. Some SDK methods use language-specific Date objects, which require different date formats. (See: Dates and Times in the API Documentation).

    Additionally for a Summary Field, you'll want to use the 'ObjectValue' to then specify the ObjectType as 'Date'. I was working with another member on this post to troubleshoot a very similar issue. (I could use Postman to update a date in a Summary Field but they were encountering some hiccups.)

    Let me know if that helped or not!

    Cheers,

    Genevieve

    Need more help? 👀 | Help and Learning Center

    こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions

  • ArielDB
    ArielDB ✭✭✭✭

    Hi @Genevieve P. ,


    I followed your instructions, but was unable to get it to work! Here you see the error I get on top, and the code from the Python-SDK on bottom. I tried going into the SDK to read what type it expects, but I couldn't find anything useful. I will say that when I do a curl command with this structure, it works. Likely I will just do this section in Curl, but I'd love to know how to make this code work in Python!


  • ArielDB
    ArielDB ✭✭✭✭
    edited 02/06/23

    I have not succeeded yet, but I am close. Using the SDK I posted the Summary Field with the following format:

    {'id':<id>, 'value':<Date in  ISO-8601 format>, 'type':'DATE'}


    It did not throw an error but it also did not update my summary.

  • ArielDB
    ArielDB ✭✭✭✭

    I did not find success. 'value' is not an attribute in a summary field object, so it doesn't change the field.

    I can post into a summary date field using 'object_value', but it posts as a string, not a date. If ever I try to make it a date type it creates the error that is shown above, or attribute date.value missing

  • ArielDB
    ArielDB ✭✭✭✭

    I found data/body that works with curl but not with the SDK. I am stumped! Error messages are above the code in the pictures below

    Python SDK:

    doing a plain request:


  • Hey @ArielDB

    My apologies for missing your follow-ups!

    I've tested this and it should work if you just set the object_value to a string with your date. Even though it's sending the content in as a string, the column type is DATE and should parse this data correctly.

    If this doesn't work, can you double check that you're on the latest version of the SDK?

    Need more help? 👀 | Help and Learning Center

    こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions

  • ArielDB
    ArielDB ✭✭✭✭

    hey, you are right that I can post a string into a date type column for some reason. That being said, I have not been successful at having the date string acknowledged by Smartsheet as a date, and have the date widget that comes up when you click a date field to show the correct date.

    ex:

    can you give me an example of a string that will post correctly into a date column? Not sure how to format it maybe

  • Hi @ArielDB

    What happens if you try adding the date without the time or timezone designation? The same as in your first comment:

    '2022-01-01T00:00:00Z'

    If this still isn't showing up correctly, can you confirm what version of the SDK you're using?

    Need more help? 👀 | Help and Learning Center

    こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions