Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

ODATA: The session could not be retrieved from the server

Posted on by 36

Hi!

We have an ODATA set-up for an instance, but we get an error when connecting to it via the webbrowser.

Below is what I can see in the event viewer.
Any idea?

RootException: NavODataServiceUnavailableException
The session could not be retrieved from the server. The application will close.
ExceptionStackTrace:
at Microsoft.Dynamics.Nav.Service.OData.Extensions.NavUserAuthenticationExtensions.CreateNavSession(NavUserAuthentication navUserAuth, IEnumerable`1 acceptLanguages, String defaultLanguage, TimeZoneInfo defaultTimeZone)
at Microsoft.Dynamics.Nav.Service.OData.V4.RouteBuilder.<>c__DisplayClass27_0.<GetNavServiceEnvironment>b__4(NavUserAuthentication tmpAuth)
at Microsoft.Dynamics.Nav.Service.OData.NavService.<>c__DisplayClass4_0.<.ctor>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Microsoft.Dynamics.Nav.Service.OData.NavService.Execute[TResult](Func`2 operation)
at Microsoft.Dynamics.Nav.Service.OData.V4.CachedModelBuilder.Build(INavServiceEnvironment serviceEnvironment)
CallerStackTrace:
at Microsoft.Dynamics.Nav.Service.OData.V4.CachedModelBuilder.Build(INavServiceEnvironment serviceEnvironment)
at Microsoft.Dynamics.Nav.Service.OData.V4.RouteBuilder.GetEdmModel(IServiceProvider serviceProvider)
at Microsoft.Dynamics.Nav.Service.OData.V4.RouteBuilder.GetEdmModelInternal(IServiceProvider serviceProvider)
at lambda_method(Closure , ServiceProvider )
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.AspNet.OData.Routing.DefaultODataPathHandler.Parse(String serviceRoot, String odataPath, IServiceProvider requestContainer, Boolean template)
at Microsoft.AspNet.OData.Routing.DefaultODataPathHandler.Parse(String serviceRoot, String odataPath, IServiceProvider requestContainer)
at Microsoft.Dynamics.Nav.Service.OData.V4.PathHandler.Parse(String serviceRoot, String odataPath, IServiceProvider requestContainer)
at Microsoft.Dynamics.Nav.Service.OData.V4.RouteConstraint.Match(HttpRequestMessage request, IHttpRoute route, String parameterName, IDictionary`2 values, HttpRouteDirection routeDirection)
at System.Web.Http.Routing.HttpRoute.ProcessConstraint(HttpRequestMessage request, Object constraint, String parameterName, HttpRouteValueDictionary values, HttpRouteDirection routeDirection)
at System.Web.Http.Routing.HttpRoute.ProcessConstraints(HttpRequestMessage request, HttpRouteValueDictionary values, HttpRouteDirection routeDirection)
at System.Web.Http.Routing.HttpRoute.GetRouteData(String virtualPathRoot, HttpRequestMessage request)
at System.Web.Http.HttpRouteCollection.GetRouteData(HttpRequestMessage request)
at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
at System.Web.Http.HttpServer.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Web.Http.Owin.HttpMessageHandlerAdapter.<InvokeCore>d__0.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at System.Web.Http.Owin.HttpMessageHandlerAdapter.InvokeCore(IOwinContext context, IOwinRequest owinRequest, IOwinResponse owinResponse)
at Microsoft.Dynamics.Nav.Service.OData.NavODataCorsMiddleware.<Invoke>d__1.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.Nav.Service.OData.NavODataCorsMiddleware.Invoke(IOwinContext context)
at Microsoft.Dynamics.Nav.Service.OData.NavODataMaxConnectionsMiddleware.<Invoke>d__1.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.Nav.Service.OData.NavODataMaxConnectionsMiddleware.Invoke(IOwinContext context)
at Microsoft.Dynamics.Nav.Service.OData.NavODataOptionsPreflightMiddleware.<Invoke>d__3.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.Nav.Service.OData.NavODataOptionsPreflightMiddleware.Invoke(IOwinContext context)
at Microsoft.Dynamics.Nav.Service.OData.NavODataTelemetryIOMiddleware.<Invoke>d__1.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.Nav.Service.OData.NavODataTelemetryIOMiddleware.Invoke(IOwinContext context)
at Microsoft.Dynamics.Nav.Service.OData.NavODataRequestCompressionMiddleware.<Invoke>d__1.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.Nav.Service.OData.NavODataRequestCompressionMiddleware.Invoke(IOwinContext context)
at Microsoft.Dynamics.Nav.Service.OData.NavODataRequestUrlMiddleware.<Invoke>d__1.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.Nav.Service.OData.NavODataRequestUrlMiddleware.Invoke(IOwinContext context)
at Microsoft.Dynamics.Nav.Service.OData.V4.NavODataExceptionHandlingMiddleware.<Invoke>d__1.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.Nav.Service.OData.V4.NavODataExceptionHandlingMiddleware.Invoke(IOwinContext context)
at Microsoft.Dynamics.Nav.Service.OData.NavODataResponseCompressionMiddleware.<Invoke>d__2.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.Nav.Service.OData.NavODataResponseCompressionMiddleware.Invoke(IOwinContext context)
at Microsoft.Dynamics.Nav.Service.OData.NavODataRequestTracingMiddleware.<Invoke>d__1.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Dynamics.Nav.Service.OData.NavODataRequestTracingMiddleware.Invoke(IOwinContext context)
at Microsoft.Owin.Hosting.Utilities.Encapsulate.Invoke(IDictionary`2 environment)
at Microsoft.Owin.Host.HttpListener.OwinHttpListener.<ProcessRequestAsync>d__5.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Owin.Host.HttpListener.OwinHttpListener.ProcessRequestAsync(HttpListenerContext context)
at Microsoft.Owin.Host.HttpListener.OwinHttpListener.<ProcessRequestsAsync>d__0.MoveNext()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run()
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(Action action, Boolean allowInlining, Task& currentTask)
at System.Threading.Tasks.Task.FinishContinuations()
at System.Threading.Tasks.Task`1.TrySetResult(TResult result)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
at System.Threading.Tasks.TaskFactory`1.<>c__DisplayClass35_0.<FromAsyncImpl>b__0(IAsyncResult iar)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.ListenerAsyncResult.IOCompleted(ListenerAsyncResult asyncResult, UInt32 errorCode, UInt32 numBytes)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

  • Suggested answer
    RobbertMeijer Profile Picture
    RobbertMeijer 36 on at
    RE: ODATA: The session could not be retrieved from the server

    I fixed it with the below command inside the shell:

    Start-NavDataUpgrade -ServerInstance <ServerInstanceName> -FunctionExecutionMode Serial -ContinueOnError

  • howeidat Profile Picture
    howeidat 35 on at
    RE: ODATA: The session could not be retrieved from the server

    Do you have multiple NAV instances running on the same server?

  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    Jeffrey Bulanadi 644 on at
    RE: ODATA: The session could not be retrieved from the server

    Hi Robberto,

     

    Have you tried logging in using the basic authentication?

     

    Basically you need to setup first web service key at your user, then to login using the web browser you need to use username and web access key.
    docs.microsoft.com/.../web-services-authentication

     

    It should resolve your issue.

    pastedimage1659902786725v1.png
    pastedimage1659903190393v1.png

    pastedimage1659903226510v1.png

     

    Keep in mind that the above authentication method will be deprecated soon as we will use OAuth 2.0

  • RobbertMeijer Profile Picture
    RobbertMeijer 36 on at
    RE: ODATA: The session could not be retrieved from the server

    Hi Hassan!

    Unfortunately, all of the above things didn't work.

  • Suggested answer
    howeidat Profile Picture
    howeidat 35 on at
    RE: ODATA: The session could not be retrieved from the server

    Hello,

    1- Please check if  OData service is enabled.

    2- add Odata port to firewall or stop the firewall on both server and client.

    3- Enable "Use NTLM Authentication" in the administration console and restart the service.

  • RobbertMeijer Profile Picture
    RobbertMeijer 36 on at
    RE: ODATA: The session could not be retrieved from the server

    I get the following error in the webbrowser:

    {"error":{"code":"Application_ServiceUnavailable","message":"The session could not be retrieved from the server. The application will close.  CorrelationId:  702fd6fa-b4d0-4252-817b-1dd3ba8c1."}}.

    I'm using type Windows as credential type. I've tried to use NavUsePassword, but with no luck. Same error.

  • Nitin Verma Profile Picture
    Nitin Verma 21,023 Moderator on at
    RE: ODATA: The session could not be retrieved from the server

    What is the error you are getting in Web browser? Are you using Web service Key with Basic Authentication?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans