You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IRestClient given by IRequestPreparation Prepare method throws Progress.Sitefinity.RestSdk.Exceptions.ErrorCodeException: The current user is not allowed access
#157
Open
chenyuAC opened this issue
Dec 19, 2024
· 3 comments
When I attempt to use it to query any content type data, it throws
System.AggregateException: One or more errors occurred. (The current user is not allowed access)
---> Progress.Sitefinity.RestSdk.Exceptions.ErrorCodeException: The current user is not allowed access
at Progress.Sitefinity.RestSdk.Client.RestClient.SendMessage[T](RequestData requestData)
at Progress.Sitefinity.RestSdk.Client.RestClient.GetItems[T](GetAllArgs args)
at Renderer.Services.RequestPreparations.Prepare(PageModel pageModel, IRestClient restClient, HttpContext context)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.WaitAllCore(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.WaitAll(Task[] tasks)
at Progress.Sitefinity.AspNetCore.Preparations.PreparationsInitializer.RunCustomRequests(IRestClient restClient, RequestArgs requestArgs, PageModel pageModel, HttpContext httpContext)
at Progress.Sitefinity.AspNetCore.Preparations.PreparationsInitializer.Initialize(IRestClient restClient, PageModel pageModel, HttpContext httpContext)
at Progress.Sitefinity.AspNetCore.Http.Proxy.DefaultProxyHandler.InitRestClient(HttpContext httpContext, String metadataHash, RequestContext requestContext, IRenderContext renderContext)
at Progress.Sitefinity.AspNetCore.Http.Proxy.DefaultProxyHandler.HandlePageModelResponse(HttpContext httpContext, HttpResponseMessage httpResponseMessage, Func`1 next)
at Progress.Sitefinity.AspNetCore.Http.Proxy.DefaultProxyHandler.TryHandleResponse(HttpResponseMessage httpResponseMessage, HttpContext httpContext, Func`1 next, Boolean disabledProxy)
at Progress.Sitefinity.AspNetCore.Http.Proxy.DefaultProxyHandler.SendHttpRequestMessage(HttpRequestMessage httpRequestMessage, Uri forwardHost, HttpClient httpClient, HttpContext context, Func`1 next, Func`2 sendRequest, ISitefinityConfig sitefinityConfig)
at Progress.Sitefinity.AspNetCore.Http.Proxy.DefaultProxyHandler.SendHttpRequestMessage(HttpRequestMessage httpRequestMessage, Uri forwardHost, HttpClient httpClient, HttpContext context, Func`1 next, Func`2 sendRequest, ISitefinityConfig sitefinityConfig)
at Progress.Sitefinity.AspNetCore.Http.Proxy.DefaultProxyHandler.<>c__DisplayClass6_0.<<TryHandleRequest>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Progress.Sitefinity.AspNetCore.Http.Proxy.DefaultProxyHandler.TryHandleRequest(HttpContext context, Func`1 next)
at Progress.Sitefinity.AspNetCore.Areas.Diagnostics.Profiling.ProxyMiddleware.Invoke(HttpContext context)
at Progress.Sitefinity.AspNetCore.Areas.Cache.ExternalCacheMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.OutputCaching.OutputCacheMiddleware.InvokeAwaited(HttpContext httpContext, IReadOnlyList`1 policies)
at Progress.Sitefinity.AspNetCore.ResourcePackages.ResourcePackagesMiddleware.Invoke(HttpContext context)
at Progress.Sitefinity.AspNetCore.Web.UI.EmbeddedResourceMiddleware.Invoke(HttpContext context)
at Progress.Sitefinity.AspNetCore.Areas.Diagnostics.Profiling.DiagnosticsMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Is the IRestClient working here? If I use the IRestClient from dependency injection as following it works
Thank you for contacting us about this.
The IRestClient that comes as a parameter in the Prepare method of the IRequestPreparation is in fact a batch client. This means it accumulates requests from all preparations and executes them at once. Therefore the result from this client should be anticipated asynchronously (for example by using ContinueWith()).
Is it possible to access this item (especially in draft state) in an IRequestPreparation implementation? I am encountering challenges querying items in draft state within our custom master-detail widget implementation using IRequestPreparation.
The default restClient uses the web service that is set in the appsettings.json file. By default it is 'api/default'. This is a frontend web service and therefore returns only live items and not drafts.
In order to fetch draft items you should use a backend web service such as 'sf/system'.
You can check this.
Another alternative is to create a custom endpoint that returns the desired item: Docs
None of the examples here make use of the IRestClient passed in
sitefinity-aspnetcore-mvc-samples/src/share-data-between-widgets/CategoryPreparation.cs
Line 18 in 5df33c7
sitefinity-aspnetcore-mvc-samples/src/master-detail/EventPreparation.cs
Line 24 in 5df33c7
When I attempt to use it to query any content type data, it throws
Is the IRestClient working here? If I use the IRestClient from dependency injection as following it works
I have
WebServiceApiKey
configured, is it related?The text was updated successfully, but these errors were encountered: