mariosimao / notion-sdk-php

A complete Notion SDK for PHP developers.
https://mariosimao.github.io/notion-sdk-php/
MIT License
156 stars 24 forks source link

[BUG] Cannot set CreatedBy #397

Closed utdrmac closed 3 days ago

utdrmac commented 3 days ago

Describe the bug CreatedBy page property does not accept User object from $notion->users()->find('111-222-33')

To Reproduce

$notionOwner = $notion->users()->find($testNotionId);
$pageProperties = [
            "Project ID" => Notion\Pages\Properties\RichTextProperty::fromString("PS999911"),
            "Customer Name" => Notion\Pages\Properties\Title::fromString("Testing Kale Title"),
            "Database Type" => Notion\Pages\Properties\Select::fromName("mysql"),
            "Created by" => $notionOwner,
            "Status" => Notion\Pages\Properties\Status::fromName("In progress"),
        ];

Error:

TypeError: Notion\Pages\Client::Notion\Pages\{closure}(): Argument #1 ($p) must be of type Notion\Pages\Properties\PropertyInterface, Notion\Users\User given

/var/www/mboehm-dev/vendor/mariosimao/notion-sdk-php/src/Pages/Client.php:48
/var/www/mboehm-dev/tests/TestCase/NotionTest.php:87

If you try to use People object, that doesn't work either.

Fix Please provide a class method for creating a CreatedBy from a User object.

utdrmac commented 3 days ago

Turns out that setting CreatedBy is not supported by the Notion API.

Some page properties are not supported via the API. A request body that includes rollup, created_by, created_time, last_edited_by, or last_edited_time values in the properties object returns an error.