Developer forum

Forum » Development » Calling /dwapi/ecommerce/products/{productId}?FilledProperties=StandardFields gives NullReferenceException

Calling /dwapi/ecommerce/products/{productId}?FilledProperties=StandardFields gives NullReferenceException

Mikkel Hammer
Mikkel Hammer
Reply

Hi DW,

As the title states, calling /dwapi/ecommerce/products/{productId}?FilledProperties=StandardFields gives this error (i've attached it as a picture aswell for better readability):

{
    "Message": "An error has occurred.",
    "ExceptionMessage": "The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.",
    "ExceptionType": "System.InvalidOperationException",
    "StackTrace": null,
    "InnerException": {
        "Message": "An error has occurred.",
        "ExceptionMessage": "Error getting value from 'StandardFields' on 'Dynamicweb.Ecommerce.ProductCatalog.ProductViewModel'.",
        "ExceptionType": "Newtonsoft.Json.JsonSerializationException",
        "StackTrace": "   at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n   at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()",
        "InnerException": {
            "Message": "An error has occurred.",
            "ExceptionMessage": "Object reference not set to an instance of an object.",
            "ExceptionType": "System.NullReferenceException",
            "StackTrace": "   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetStandardFieldValues(ProductViewModelSettings settings, Product product)\r\n   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass3_1.<BulkCreateView>b__49()\r\n   at System.Lazy`1.CreateValue()\r\n   at System.Lazy`1.LazyInitValue()\r\n   at Dynamicweb.Ecommerce.ProductCatalog.ProductViewModel.get_StandardFields()\r\n   at GetStandardFields(Object )\r\n   at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)"
        }
    }
}

But just calling /dwapi/ecommerce/products/{productId} populates the StandardFields property correctly, so there's something in the FilledProperties query that goes wrong.
Looks like the method GetStandardFieldValues being called is missing.

Best regards,
Mikkel Hammer

dwerror.png

Replies

 
Nicolai Pedersen
Reply

Hej Mikkel

we have actually just removed that property because it is redundant data and causes performance issues when generated.

how are you using this - and why not the properties?

 
Mikkel Hammer
Mikkel Hammer
Reply

Hi Nicolai,

We're running on a 9.13.9 with ecommerce 1.13.59 and webapi 0.14.10, that might be the issue then?

I've attached the result we get from /dwapi/ecommerce/products/{productId}.
The only place where we can get the product image is in StandardFields -> ProductImageDefault.
All the other images is set to photo-coming.png, which is our "missing photo" image.

But since the result from /dwapi/ecommerce/products/{productId} is 1482 lines, we're trying to reduce the data we get by using ?FilledProperties=StandardFields (and a few others),
and then get ProductImageDefault from there, which results in the error i mentioned.

Best regards,
Mikkel Hammer

 
Nicolai Pedersen
Reply

Thank you for the explanation.

Where does the image that is available (PIM_IMG_png_72_dpi_1000x1000/71091.png) come from? Is it an image pattern, set on the product, in details or how is it applied?

And how is your image patterns setup - pls. provide screendumps - also if image pattern settings

Seems like we have a bug at hand that we will need to look into.

BR Nicolai

 
Mikkel Hammer
Mikkel Hammer
Reply

If im not mistaking, it seems the product image is coming from our image pattern.
I've inserting a bunch of images below and hope you can see the settings you're looking 😅

Best regards,
Mikkel Hammer







 

You must be logged in to post in the forum