November Happy Hour will be moved to Thursday December 5th.

Commerce 12.2.0: Exception when reading from ServiceAPI 5.0

Vote:
 

Hi,

I updated to ServiceAPI 5.0 and EPiServer.Commerce 12.2.0 some days ago. Now when I try to fetch all catalogs (episerverapi/commerce/catalogs) from service API I get this exception:

"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":"Unable to cast object of type 'Castle.Proxies.ProductContentProxy' to type 'EPiServer.Commerce.Catalog.ContentTypes.NodeContent'.","ExceptionType":"System.InvalidCastException","StackTrace":"   at System.Linq.Enumerable.d__95`1.MoveNext()\r\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n   at EPiServer.ServiceApi.Commerce.Controllers.Catalog.Construction.CatalogModelFactory.MapCatalogContent(CatalogContent catalogContent)\r\n   at EPiServer.ServiceApi.Commerce.Controllers.Catalog.Construction.CatalogModelFactory.b__2_0(CatalogContent c)\r\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, 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.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content)\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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.WebHost.HttpControllerHandler.d__1b.MoveNext()"}}

It worked before the update. There is no added content after the update. Have anyone seen this before?

Thanks,

Rickard

#194390
Jun 20, 2018 9:49
Vote:
 

Strange. It works well for me. How is your catalog structured? Does it have nodes and entries as direct children?

#194391
Jun 20, 2018 10:27
Vote:
 

I have this:

Catalog root (type: catalog root)

 -books (type: catalog)

  -- (contains lots of variants)

  -- X (type: category)

  -- X2 (type: category)

 -enbooks (type: catalog)

#194395
Jun 20, 2018 11:20
Vote:
 

Please contact our developer support service for further assistance. When we have your databases we will be able to investigate properly 

#194397
Jun 20, 2018 11:33
Vote:
 

Hi Rickard, we received the ticket from you. However it might be easier to investigate the problem if you can send me the catalog directly, my email is quma at episerver.com 

#194636
Jun 27, 2018 8:47
Vote:
 

There is something wrong with your data, it got the content types wrong. I'm having hard time finding exactly what, but we probably just be more tolerant on the issue. A fix will be coming in ServiceAPI 5.0.1

#194652
Jun 27, 2018 12:11
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.