Failing to post date value to Summary field
我使用python sdk,和我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
-
Genevieve P. Employee Admin
Hey@ArielDB
The Smartsheet API needs dates to be formatted inISO-8601format: 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 theObjectTypeas 'Date'. I was working withanother member on this postto 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
-
ArielDB ✭✭✭
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 ✭✭✭
我还没有成功,但是我关闭。使用the SDK I posted the Summary Field with the following format:
{'id':
, 'value': ISO-8601format>, 'type':'DATE'} It did not throw an error but it also did not update my summary.
-
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 ✭✭✭
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:
-
Genevieve P. Employee Admin
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?
-
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
-
Genevieve P. Employee Admin
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?