Developer forum

Forum » Development » Unable to get cart via /dwapi/ecommerce/carts/{secret} after adding product to cart after upgrading to 9.13.3

Unable to get cart via /dwapi/ecommerce/carts/{secret} after adding product to cart after upgrading to 9.13.3

Mikkel Hammer
Mikkel Hammer
Reply

Hi DW,

As the title says, after upgrading to 9.13.3, we get this error when trying to get the cart via dwapi after you a product to the cart.
It's just on my locale machine so i don't have a site to reference to.

{
    "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 'OrderLines' on 'Dynamicweb.Ecommerce.Frontend.OrderViewModel'.",
        "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.<>c__DisplayClass1_1.<BulkCreateView>b__2()\r\n   at Dynamicweb.Ecommerce.ProductCatalog.ViewModelPropertyFiller`1.Fill[S](T model, String propertyName, Func`1 source)\r\n   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.BulkCreateView(OrderLineViewModelSettings settings, IEnumerable`1 orderLines)\r\n   at System.Lazy`1.CreateValue()\r\n   at System.Lazy`1.LazyInitValue()\r\n   at GetOrderLines(Object )\r\n   at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)"
        }
    }

}

We had no problem getting the cart before adding a product to it.
The steps i did to create this error was:

Create cart via: /dwapi/ecommerce/carts?CurrencyCode=DKK&CountryCode=DK&LanguageId=LANG1
Add product with: /dwapi/ecommerce/carts/afe44123155a4433bdc339d52d8ff8c8/items/ with the body

{

    "ProductId""SGK070",
    "ProductVariantId""SP10642.SP5786",
    "Quantity"1
}

Get cart via /dwapi/ecommerce/carts/afe44123155a4433bdc339d52d8ff8c8/.
And then the error occurs


I tried creating a cart through our normal shop, adding a random product and then accessing the cart via the endpoint and the same error occurs aswell.

Hope you can help us sort it out.

 


Best regards,
Mikkel


Replies

 
Matthias Sebastian Sort Dynamicweb Employee
Matthias Sebastian Sort
Reply
This post has been marked as an answer

Hi Mikkel,

Seems like you're correct about the error/bug.

I can located it down to a call where we do a lookup for the variant option, parsing the UnitId, and seems like this is where it goes wrong.

I'll do some more research on it :)

I have now made a bug-fix and hopefully it will be released on Dynamicweb.Ecommerce 1.13.24 :D

BR

Matthias Sort

Votes for this answer: 1
 
Mikkel Hammer
Mikkel Hammer
Reply

Hi again Matthias,

Do you know if the bug-fix got released with Dynamicweb.Ecommerce 1.13.24.
I see there was an release 5 hours ago on nuget.org, but i can't see what was released with it on there :)

Best regards,

Mikkel

 
Matthias Sebastian Sort Dynamicweb Employee
Matthias Sebastian Sort
Reply
This post has been marked as an answer

Hi Mikkel,

It's released on version 1.13.25 (released 10 min ago) :D

BR

Matthias Sort

Votes for this answer: 1

 

You must be logged in to post in the forum