DEV Community

Michael Benjamin
Michael Benjamin

Posted on

Issue when trying to push an entry to a table via Notion API w/ Python

Trying to push entry to Notion page using below Code

payload = {
                "parent": {
                "type": "database_id",
                "database_id": "<id>"
                },
                "archived": False,
                "properties": 
                    "Time": {
                        "id": "B%7Dtt",
                        "type": "date",
                        "date": {
                        "start": "2022-12-01T00:00:00.000-05:00",
                        "end": "2022-12-01T00:30:00.000-05:00",
                        "time_zone": "America/New_York"
                        }
                    },
                    "Duration": {
                        "id": "RFUO",
                        "type": "rich_text",
                        "rich_text": [
                            {
                                "type": "text",
                                "text": {
                                    "content": duration,
                                },
                                "annotations": {
                                    "bold": False,
                                    "italic": False,
                                    "strikethrough": False,
                                    "underline": False,
                                    "code": False,
                                    "color": "default"
                                },
                            }
                        ]
                    },
                    "Client ID": {
                        "id": "XFyx",
                        "type": "rich_text",
                        "rich_text": [
                            {
                                "type": "text",
                                "text": {
                                    "content": cId,
                                },
                                "annotations": {
                                    "bold": False,
                                    "italic": False,
                                     "strikethrough": False,
                                    "underline": False,
                                    "code": False,
                                    "color": "default"
                                },
                            }
                        ]
                    },
                    "Project ID": {
                        "id": "luI%3C",
                        "type": "rich_text",
                        "rich_text": [
                            {
                                "type": "text",
                                "text": {
                                    "content": pId,
                                },
                                "annotations": {
                                    "bold": False,
                                    "italic": False,
                                    "strikethrough": False,
                                    "underline": False,
                                    "code": False,
                                    "color": "default"
                                },
                            }
                        ]
                    },
                    "Description": {
                        "id": "%7BBms",
                        "type": "rich_text",
                        "rich_text": [
                            {
                                "type": "text",
                                "text": {
                                    "content": task['description'],
                                },
                                "annotations": {
                                    "bold": False,
                                    "italic": False,
                                    "strikethrough": False,
                                    "underline": False,
                                    "code": False,
                                    "color": "default"
                                },
                            }
                        ]
                    }
                    }
                }
Enter fullscreen mode Exit fullscreen mode

But getting this error

"message": "body failed validation. Fix one:\nbody.properties.Time.type should be not present, instead was `\"date\"`.\nbody.properties.Time.date should be not present, instead was `{\"start\":\"2022-12-06 16:00:00-05:00\",\"end\":\"2022-12-06 ...`.\nbody.properties.Time.name should be defined, instead was `undefined`.\nbody.properties.Time.start should be defined, instead was `undefined`."
Enter fullscreen mode Exit fullscreen mode

JSON is formatted exactly as returned by Notion when looking at existing entries from API:

"Time": {
                    "id": "B%7Dtt",
                    "type": "date",
                    "date": {
                        "start": "2022-12-01T00:00:00.000-05:00",
                        "end": "2022-12-01T00:30:00.000-05:00",
                        "time_zone": null
                    }
                },
Enter fullscreen mode Exit fullscreen mode

Any help on this? Tried a lot of different things and can't get it to work. If anyone has pushed a time property to a table page before maybe you'd know. Odd thing was I swear it was working a few weeks ago.

Thanks in advance for any suggestions.

Top comments (0)