Description
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'.