1

I'm trying to use Notion api and Notion SDK for .Net to share some pages to external users by email. There is a People property in Page object. But I get an error if I try to add this property to an existing page:

var page = await client.Pages.RetrieveAsync(myPageId);
page.Properties.Add("people", new PeoplePropertyValue() {Id = "Owners", People = users.Results});
await client.Pages.UpdatePropertiesAsync(myPageId, page.Properties);

Error message for pages with database parent object:

Notion.Client.NotionApiException : people is not a property that exists.
Data:
  StatusCode: BadRequest
  NotionApiErrorCode: InvalidJSON
   at Notion.Client.RestClient.SendAsync(String requestUri, HttpMethod httpMethod, IDictionary`2 queryParams, IDictionary`2 headers, Action`1 attachContent, CancellationToken cancellationToken)

Error message for pages with page parent object:

Notion.Client.NotionApiException : body failed validation. Fix one:
body.parent.database_id should be defined, instead was `undefined`.
body.properties.people should be not present, instead was `{"type":"people","people":[{"object":"user","id":"39636...`.
Data:
  StatusCode: BadRequest
  NotionApiErrorCode: InvalidJSON
   at Notion.Client.RestClient.SendAsync(String requestUri, HttpMethod httpMethod, IDictionary`2 queryParams, IDictionary`2 headers, Action`1 attachContent, CancellationToken cancellationToken)

I also tried to create a new page with people property but I had the same error message.

await client.Pages.CreateAsync(new PagesCreateParameters()
    {
        Cover = new ExternalFile()
        {
            External = new ExternalFile.Info { Url = coverUrlString }
        },
        Children = new List<IBlock>
        {
            new QuoteBlock
            {
                Quote = new QuoteBlock.Info
                    { Text = new[] { new RichTextText() { Text = new Text() { Content = pageContentText } } } }
            }
        },
        Icon = new EmojiObject { Emoji = "" },
        Parent = new ParentPageInput { PageId = parentPageId }, // or ParentDataBaseInput
        Properties = new Dictionary<string, PropertyValue>
        {
            ["title"] = new TitlePropertyValue {Id = "KpQq", Title = new List<RichTextBase>() {new RichTextText(){ Text = new Text() { Content = pageTitleText } }}},
            ["people"] = new PeoplePropertyValue()
            {
                Id = "Owners",
                People = users.Results
            }
        }
    });

I also tried to use Notion-Sharp with same result:

INotion client2 = Notion.Notion.NewClient(bearerToken);
await client2.CreatePageAsync(new Page()
{
    Cover = new File.External { Uri = new Uri(coverUriText) },
    Parent = new Parent.Database() {Id = Guid.Parse(parentDatabaseIdText)},
    Properties = new Dictionary<string, PropertyValue>
    {
        ["title"] = new PropertyValue.Title 
            { Id = "Title", Name = "MyTitle", Content = new []{new RichText.Text() {Content = titleText}}},
        ["people"] = new PropertyValue.People
        {
            Id = "Owners",
            Value = new[] { new User.Person { Email = myUserEmail } }
        }
    }
});

Error message with database parent object:

Notion.NotionException : people is not a property that exists.

Error message with page parent object:

Notion.NotionException : body failed validation. Fix one:
body.parent.database_id should be defined, instead was `undefined`.
body.properties.people should be not present

Is there a way to share a page to an external user in notion api? Is there a way to change read and write rights for a page to an existing workspace user?

Vadim Martynov
  • 8,602
  • 5
  • 31
  • 43

1 Answers1

1

Not possible with the current public API.

You can use their SCIM endpoint to add Groups, add Members, and add Members to Groups (which can be used to facilitate access), but there is not a way to grant access to a specific Page via email of Member. This is also only available on the Enterprise plan.

Guests cannot be added to Groups so your ask is a non-starter for now, unless you want to use private APIs which could theoretically get you banned.

typeoneerror
  • 55,990
  • 32
  • 132
  • 223