Skip to content

DatabaseClient throws JsonSerializationException : Could not create an instance of type Notion.Client.IPageIcon. #424

Closed
@Turochamp

Description

@Turochamp

Describe the bug
When attempting to query a database that contains icons an exception is thrown:

Message: 
Newtonsoft.Json.JsonSerializationException : Could not create an instance of type Notion.Client.IPageIcon. Type is an interface or abstract class and cannot be instantiated. Path 'type', line 1, position 19171.

Stack Trace: 
JsonSerializerInternalReader.CreateNewObject(JsonReader reader, JsonObjectContract objectContract, JsonProperty containerMember, JsonProperty containerProperty, String id, Boolean& createdFromNonDefaultCreator)
JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
JsonSerializerProxy.DeserializeInternal(JsonReader reader, Type objectType)
JsonSerializer.Deserialize(JsonReader reader, Type objectType)
JsonSubtypes.ThreadStaticReadObject(JsonReader reader, JsonSerializer serializer, JToken jToken, Type targetType)
JsonSubtypes.ReadObject(JsonReader reader, Type objectType, JsonSerializer serializer)
JsonSubtypes.ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
JsonSubtypes.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
<20 more frames...>
JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
JsonSerializer.Deserialize(JsonReader reader, Type objectType)
JsonSerializer.Deserialize[T](JsonReader reader)
HttpResponseMessageExtensions.ParseStreamAsync[T](HttpResponseMessage response, JsonSerializerSettings serializerSettings)
RestClient.PostAsync[T](String uri, Object body, IEnumerable1 queryParams, IDictionary2 headers, JsonSerializerSettings serializerSettings, CancellationToken cancellationToken)
DatabasesClient.QueryAsync(String databaseId, DatabasesQueryParameters databasesQueryParameters, CancellationToken cancellationToken)

To reproduce

var queryParams = new DatabasesQueryParameters
{
    Filter = null,
    Sorts = null,
    StartCursor = null,
    PageSize = null,
    FilterProperties = null
};

_logger.LogDebug("Querying Notion database with ID: {DatabaseId}", _databaseId);
var queryResult = await _notionClient.Databases.QueryAsync(_databaseId, queryParams, CancellationToken.None);

_logger.LogInformation("Successfully fetched customer teams from Notion.");

return queryResult.Results.Select(page => MapToCustomerTeam(page)).ToList();

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