How to write to a Smartsheet "Restrict to date only" cell using API?
Hello All! Need your help. With Python using Smartsheet API, I am trying to write to a date only column. I am getting the below error. v1=datetime.datetime.utcnow().date() new_cell = ss_client.models.Cell({'column_id': 123456789, 'object_value': v1, 'strict': False}) {"result": {"errorCode": 1012, "message": "Required object attribute(s) are missing from your request: cell.value.", "name": "ApiError", "recommendation": "Do not retry without fixing the problem. ","statusCode": 400}} new_cell = ss_client.models.Cell({'column_id': 123456789, 'object_value': "2019-10-13", 'strict': False}) "errorCode": 5536, "message": "The value \"2019-10-13\" could not be saved in column \"col3\". This column is restricted to DATE values only."
Best Answer
-
Hi @Devi
Are you getting a new error, or is it the same message?
I'm not that familiar with Python however I don't believe you need an 'object_value' parameter, it should just be Value. Try:
v1 = datetime.datetime.now().isoformat() #v1 = 2022-10-25T08:48:45.736949 new_cell = ss_client.models.Cell({'column_id': column_map[k1], 'value': v1,})
https://smartsheet.redoc.ly/#operation/update-rows
Cheers!
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Answers
-
Hi @Devi
When you input a date via the API, you'll need to write it in ISO-8601 format, that is, YYYY-MM-DDTHH:MM:SSZ.
Here's the documentation on this: Dates and Times - Smartsheet API Documentation
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Hi @Genevieve P. Thank You for the reply. I did try converting the date to ISO-8601 format, but still the script failed to write to the date restricted column. I even tried to convert the input date value(v1) from str object to date object/tried to write date only, but no luck. What is the type/format required (for 'object_value' parameter) to write to a date restricted cell?
v1 = datetime.datetime.now().isoformat() #v1 = 2022-10-25T08:48:45.736949 new_cell = ss_client.models.Cell({'column_id': column_map[k1], 'object_value': v1, 'strict': False})
Thank You in advance!
-
Hi @Devi
Are you getting a new error, or is it the same message?
I'm not that familiar with Python however I don't believe you need an 'object_value' parameter, it should just be Value. Try:
v1 = datetime.datetime.now().isoformat() #v1 = 2022-10-25T08:48:45.736949 new_cell = ss_client.models.Cell({'column_id': column_map[k1], 'value': v1,})
https://smartsheet.redoc.ly/#operation/update-rows
Cheers!
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Thanks a lot Genevieve! It's working now after replacing 'object_value' with 'value'.
-
Awesome, glad to hear it! 🙂
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.2K Get Help
- 419 Global Discussions
- 221 Industry Talk
- 461 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 142 Just for fun
- 58 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives