Posted on 16/11/2022 15:29:31
Hi DW
We have an issue on DW 9.14.1 using the Web API to get products for a custom view. We are using Live Integration version 7.0.5 with Live Prices enabled.
The problem is that we can get the products fine if we are querying them anonymously from the WebAPI using this endpoint "/ecommerce/products/{id}?currencycode={currencyCode}&countrycode={countryCode}&LanguageId={languageId}&ShopId={shopId}". But if we try to query the same endpoint using an authenticated user by sending the bearer token we get this error:
{
"Message": "An error has occurred.",
"ExceptionMessage": "Object reference not set to an instance of an object.",
"ExceptionType": "System.NullReferenceException",
"StackTrace": " at Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products.ProductManager.FetchProductInfosInternal(Dictionary`2 productsForRequest, CacheLevel productCacheLevel, LiveContext context, Settings settings, Logger logger, Boolean updateCache)\r\n at Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products.ProductManager.FetchProductInfos(Dictionary`2 products, LiveContext context, Settings settings, Logger logger, Boolean updateCache)\r\n at Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products.ProductPriceProvider.PreparePrices(PriceContext context, IEnumerable`1 selections)\r\n at Dynamicweb.Ecommerce.Prices.PriceManager.PreparePrices(PriceContext context, IEnumerable`1 selections)\r\n at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.PreparePrices(PriceContext context, Boolean& pricesHasBeenPrepared, Object lock, IList`1 products)\r\n at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetPrices(PriceViewModelSettings settings, IList`1 products, Boolean& pricesHasBeenPrepared, Object lock, Product product)\r\n at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass3_1.<BulkCreateView>b__44()\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(ProductViewModelSettings settings, Boolean isRecursive, IList`1 products)\r\n at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.CreateView(ProductViewModelSettings settings, Product product)\r\n at Dynamicweb.Ecommerce.WebAPI.Controllers.ProductsController.GetProduct(String id, String variantId, ProductViewModelSettings request)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, 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.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\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.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\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.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\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.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\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.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\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.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
This does not give us much to go for, so I'm looking for some kind of extended info on where this goes wrong.
This only happens if prices are fetched from ERP using Live Integration. If we use a DW user with LivePrices disabled this problem does not occur (obviously from the namespace of the error). I have disabled all our custom extensions but to no avail. I can see that the Live Integration is indeed being called on API request and returns a response indicating succes. Request and response is attached to this comment.
So somewhere after ERP has been called this fails with a null reference exception. Any idea how to proceed from here?
BR Chris