Closed Scantheus closed 1 year ago
Looking through open issues, this looks related to #345.
@Scantheus I'm unable to spend time on the library in recent past. In case you would like to raise a PR for this I would be very much happy to accept it.
@Scantheus I tried producing this on local using SDK and Postman - found that this is something related to Notion API.
That being said Notion API expect the `SelectPropertyValue.Select
to be null (to reset values when updating multiple properties at once) - I noticed if you set the SelectPropertyValue.Select
property null the library ignore null which I have fixed it in PR - #355
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