8000 Exception when attempting to set Select property to nothing. · Issue #353 · notion-dotnet/notion-sdk-net · GitHub
[go: up one dir, main page]

Skip to content 8000
Exception when attempting to set Select property to nothing. #353
Closed
@Scantheus

Description

@Scantheus

You can set a Select property to nothing by set the PropertyValue to null.
However, if you try to include another Select property with a value, it generates an exception.

Consider a table with two Select properties named "SelectProperty1" and "SelectProperty2".
Set one property to null and another to a value.
This generates an exception. If you call UpdateSync with only one of the properties, it works.

Dictionary<string, PropertyValue> updateProperties = new Dictionary<string, PropertyValue>();
updateProperties.Add("SelectProperty1", null);
updateProperties.Add("SelectProperty2, new SelectPropertyValue() { Select = new SelectOption() { Name = "SelectValue1" } });

try
{
await Client.Pages.UpdateAsync(pageId, new PagesUpdateParameters() { Properties = updateProperties });
}
catch (NotionApiException ex)
{
Debug.WriteLine($"Exception : Status Code {ex.StatusCode}, API Error {ex.NotionAPIErrorCode} : {ex.Message}";
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}

Resulting Exception:
Exception : Status Code BadRequest, API Error ValidationError : body failed validation. Fix one:
body.properties.SelectProperty2.id should be defined, instead was 'undefined'.
body.properties.SelectProperty2.name should be defined, instead was 'undefined'.
body.properties.SelectProperty2.start should be defined, instead was 'undefined'.

SelectEmptyBug.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0