Skip to content

Can't deserialize response from NHS Search which says it complies with schema.org #91

@horizondave

Description

@horizondave
            var content = response.Content;
            var srp = JsonConvert.DeserializeObject<Schema.NET.SearchResultsPage>(content);

Newtonsoft.Json.JsonSerializationException
HResult=0x80131500
Message=Error setting value to 'Breadcrumb' on 'Schema.NET.SearchResultsPage'.
Source=Newtonsoft.Json
StackTrace:
at Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
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.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)

To Reproduce

Register for API access at https://developer.api.nhs.uk/documentation/content-api?filter=news
Call the "Behind The Headline" / "All News" API
Try to deserialize the result as above.
(or do the same with the sample response attached)

Expected behaviour

The response should deserialize correctly without an error.

Schema Objects

SearchResultPage

ExampleBehindTheHeadlinesResponse.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssues describing a bug or pull requests fixing a bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions