Wednesday, November 14, 2018

Status Code: 401; Unauthorized - while communicating with Sitecore commerce API

While working on Sitecore commerce 9, I was getting the below exception:

Exception: Microsoft.OData.Client.DataServiceClientException
Message: Status Code: 401; Unauthorized                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
Source: Microsoft.OData.Client
   at Microsoft.OData.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult)

   at Microsoft.OData.Client.QueryResult.EndExecuteQuery[TElement](Object source, String method, IAsyncResult asyncResult)

The exception message was misleading as it conveyed that there is something wrong with the certificate thumbprint and communication between the website and commerce is not working as expected. 

After digging into logs from commerce authoring environment found that the exception was because one of the stored procedure was missing. After installing the SP was able to resolve this exception. 

So the idea is that the exceptions thrown while interacting with Sitecore commerce can be misleading. To get to the root cause check the logs on the commerce engine web apps. 


No comments:

Post a Comment