notion-dotnet / notion-sdk-net

A Notion SDK for .Net
MIT License
181 stars 46 forks source link

RetrievePagePropertyItem for status property failed #325

Closed hikeda closed 1 year ago

hikeda commented 1 year ago

If the page contains status property, PagesClient.RetrievePagePropertyItem throws the following exception. (version: 4.0.0-preview-5.9.15.2022)

Newtonsoft.Json.JsonSerializationException: Could not create an instance of type Notion.Client.IPropertyItemObject. Type is an interface or abstract class and cannot be instantiated. Path 'object', line 1, position 10.
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(JsonReader reader, JsonObjectContract objectContract, JsonProperty containerMember, JsonProperty containerProperty, String id, Boolean& createdFromNonDefaultCreator)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at JsonSubTypes.JsonSubtypes.ThreadStaticReadObject(JsonReader reader, JsonSerializer serializer, JToken jToken, Type targetType)
   at JsonSubTypes.JsonSubtypes.ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
   at Notion.Client.Extensions.HttpResponseMessageExtensions.ParseStreamAsync[T](HttpResponseMessage response, JsonSerializerSettings serializerSettings)
   at Notion.Client.RestClient.GetAsync[T](String uri, IDictionary`2 queryParams, IDictionary`2 headers, JsonSerializerSettings serializerSettings, CancellationToken cancellationToken)
   at Notion.Client.PagesClient.RetrievePagePropertyItem(RetrievePropertyItemParameters retrievePropertyItemParameters)

This page does not describe the status property, but actually returns the following JSON

{
    "object": "property_item",
    "type": "status",
    "id": "_PDs",
    "status": {
        "id": "7e50ec50-e5ee-40ee-88e3-36811e956e88",
        "name": "In progress",
        "color": "blue"
    }
}
KoditkarVedant commented 1 year ago

@hikeda I think we should also open issue at Notion for updating the document.

KoditkarVedant commented 1 year ago

Fix is available in 4.0.0-preview-6.9.19.2022

KoditkarVedant commented 1 year ago

4.0.0 Released