0

After I deploy Sitecore.Commerce.Engine.SDK.7.0.55, I use postman and call to API /GenericSearch() follow this doc:

https://doc.sitecore.com/xp/en/developers/101/sitecore-experience-commerce/search-for-a-commerce-entity-using-the-genericsearch-api.html

I can not get a result similar to this document and get the below error. error image error Forbidden

00232 14:54:41 ERROR SitecoreConnectionManager: RETRY 1 out of 3 with ERROR Forbidden from GET /sitecore/api/ssc/item/?path=%2Fsitecore%2FCommerce%2FCommerce%20Control%20Panel%2FStorefront%20Settings%2FStorefronts%2FStorefront&database=master&language=en
00290 15:29:45 ERROR CommerceController.OnActionExecuting.Forbidden: User not allowed for action /api/GenericSearch()
00069 15:29:52 ERROR Connection ID ""18086456105130525033"", Request ID ""8000016e-0000-fb00-b63f-84710c7967bb"": An unhandled exception was thrown by the application.
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The required antiforgery cookie ".AspNetCore.Antiforgery.TinCpCZNkek" is not present.
   at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateRequestAsync(HttpContext httpContext)
   at Sitecore.Commerce.Core.CommerceODataController.ValidateAntiForgery(ActionExecutingContext context)
   at Sitecore.Commerce.Core.CommerceODataController.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Sitecore.Commerce.Core.ValidateCommerceConnectTokenMiddleware.Invoke(HttpContext context)
   at Sitecore.Commerce.Core.RoleAuthorizationMiddleware.Invoke(HttpContext context)
   at Sitecore.Commerce.Core.ValidateRolesHeaderMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Sitecore.Framework.Diagnostics.DiagnosticMetadataMiddleware.Invoke(HttpContext context)
   at Sitecore.Framework.Diagnostics.DiagnosticPageMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()

When I check logs, I see that the API is blocked and the user is not allowed. How can I resolve it?

1
  • From the error it looks like its trying to connect to Sitecore and is failing. Check Plugin.Content.PolictSet-1.0.0.json file, if the SitecoreConnectionPolicy values are rightly set in data\Environments folder. Mainly host, username, password. This will allow the connection to Sitecore. Do not forget to Bootstrap if the changes are made to config. Also set the AntiForgeryEnabled to False in config.json file. May 24, 2022 at 14:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.