Skip to content

Exception when attempting to set Select property to nothing. #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Scantheus opened this issue Jan 20, 2023 · 3 comments
Closed

Exception when attempting to set Select property to nothing. #353

Scantheus opened this issue Jan 20, 2023 · 3 comments
Milestone

Comments

@Scantheus
Copy link

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

@Scantheus
Copy link
Author

Looking through open issues, this looks related to #345.

@KoditkarVedant
Copy link
Contributor

@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.

@KoditkarVedant
Copy link
Contributor

@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 theSelectPropertyValue.Select` property null the library ignore null which I have fixed it in PR - #355

@KoditkarVedant KoditkarVedant added this to the 4.1.0 milestone Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants