jomei / notionapi

A Notion API SDK, written in Golang

Home Page:https://pkg.go.dev/github.com/jomei/notionapi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parent in PageCreateRequest is invalid

vaayne opened this issue · comments

parent is databaseParent or PageParent

use a map format like

{
    "parent": {
        "database_id": "abcd"
    }
}

Current in sdk is

{
    "parent": {
        "type": "database_id",
        "database_id": "abcd"
    }
}

Hey, @vaayne !
I didn't catch the point of this issue.
current Parent struct is

type Parent struct {
	Type       ParentType `json:"type,omitempty"`
	PageID     PageID     `json:"page_id,omitempty"`
	DatabaseID DatabaseID `json:"database_id,omitempty"`
}

so you can easily omit any of provided fields. If you don't need the type property in your request, just left it empty.

Could you provide more information about this problem?

@jomei I think it is Notion's bug.

https://developers.notion.com/reference/post-page
The example is different from the struct. And the one in example worked.

Still don't understand.
Could you please provide an example of a valid request or response that doesn't cover by current structure?

This is wrong request, return 400

{
    "parent": {
        "type": "database_id",
        "database_id": "abcd"
    }
}

image

This is right request

{
    "parent": {
        "database_id": "abcd"
    }
}

image

So, the type is not optional.

type is required for parsing responses. For requests, you can leave this property empty and everything will be OK, right?

type is required for parsing responses. For requests, you can leave this property empty and everything will be OK, right?

Right.