dstotijn / go-notion

Go client for the Notion API.
MIT License
380 stars 39 forks source link

Adding Phone number crashes program #56

Open shivarammysore opened 2 months ago

shivarammysore commented 2 months ago

I have a Go program that adds information to Notion DB page. I am able to post information such as name, email to the DB. But, phone number is causing the problem. I can assure you that phone_number value is not empty. What I am doing wrong? Thanks!

    properties := notion.DatabasePageProperties{
        "Reason": notion.DatabasePageProperty{
            Title: []notion.RichText{
                {
                    Text: &notion.Text{
                        Content: formData["reason"],
                    },
                },
            },
        },
        "first_name": notion.DatabasePageProperty{
            RichText: []notion.RichText{
                {
                    Text: &notion.Text{
                        Content: formData["first_name"],
                    },
                },
            },
        },
        "email": notion.DatabasePageProperty{
            Email: notion.StringPtr(formData["email"]),
        },
        "Phone": notion.DatabasePageProperty{
            PhoneNumber: notion.StringPtr(formData["phone_number"]),
            //PhoneNumber: {phone_number: notion.StringPtr(formData["phone_number"])},
        },
}

crash stack trace:

2024/08/23 18:20:55 Failed to create page in Notion database: notion: failed to create page: body failed validation. Fix one:
body.properties.Phone.title should be defined, instead was `undefined`.
body.properties.Phone.rich_text should be defined, instead was `undefined`.
body.properties.Phone.number should be defined, instead was `undefined`.
body.properties.Phone.url should be defined, instead was `undefined`.
body.properties.Phone.select should be defined, instead was `undefined`.
body.properties.Phone.multi_select should be defined, instead was `undefined`.
body.properties.Phone.people should be defined, instead was `undefined`.
body.properties.Phone.email should be defined, instead was `undefined`.
body.properties.Phone.phone_number should be populated or `null`, instead was `""`.
body.properties.Phone.date should be defined, instead was `undefined`.
body.properties.Phone.checkbox should be defined, instead was `undefined`.
body.properties.Phone.relation should be defined, instead was `undefined`.
body.properties.Phone.files should be defined, instead was `undefined`.
body.properties.Phone.status should be defined, instead was `undefined`.
body.properties.Message.id should be defined, instead was `undefined`.
body.properties.Message.name should be defined, instead was `undefined`.
body.properties.Message.start should be defined, instead was `undefined`. (code: validation_error, status: 400)