REST API Https UD 27

PS C:\Users\Lx\GitPerso> Invoke-RestMethod -Uri $uri -Method GET -Headers @{ Authorization = "Bearer $($Result.Token)"}
22:17:57 [Info] Microsoft.AspNetCore.Hosting.Internal.WebHost Request starting HTTP/1.1 GET http://localhost:10001/api/authtest
22:17:57 [Info] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker Route matched with {action = "GetEndpoint", controller = "Component"}. Executing action UniversalDashboard.Controllers.ComponentController.GetEndpoint (UniversalDa
shboard)
22:17:57 [Info] Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler Successfully validated the token.
22:17:57 [Debug] AuthorizationHandler Configuring authorization for session:ae2115a3-df7f-4e88-8ee1-14f503308a48
22:17:57 [Debug] AuthorizationHandler No valid authorization policies for session.
22:17:57 [Debug] AuthorizationHandler Valid roles for session: admin
22:17:57 [Info] Microsoft.AspNetCore.Authorization.DefaultAuthorizationService Authorization was successful.
22:17:57 [Debug] PowerShellExecutionService ExecutionService constructor
22:17:57 [Debug] PowerShellExecutionService ExecutionService constructor
22:17:57 [Info] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker Executing action method UniversalDashboard.Controllers.ComponentController.GetEndpoint (UniversalDashboard) - Validation state: Valid
22:17:57 [Info] ComponentController GetEndpoint - authtest
22:17:57 [Debug] AuthorizationService No authorization policies or roles defined.
22:17:57 [Debug] PowerShellExecutionService Scope variables--------------
22:17:57 [Debug] PowerShellExecutionService Context variables--------------
22:17:57 [Debug] PowerShellExecutionService Request = Microsoft.AspNetCore.Http.Internal.DefaultHttpRequest
22:17:57 [Debug] PowerShellExecutionService Response = Microsoft.AspNetCore.Http.Internal.DefaultHttpResponse
22:17:57 [Debug] PowerShellExecutionService User = Bartek
22:17:57 [Debug] PowerShellExecutionService MemoryCache = Microsoft.Extensions.Caching.Memory.MemoryCache
22:17:57 [Debug] PowerShellExecutionService UDConnectionManager = UniversalDashboard.Services.ConnectionManager
22:17:57 [Debug] PowerShellExecutionService DashboardHub = Microsoft.AspNetCore.SignalR.Internal.HubContext`1[UniversalDashboard.DashboardHub]
22:17:57 [Debug] PowerShellExecutionService Cache = Microsoft.Extensions.Caching.Memory.MemoryCache
22:17:57 [Debug] PowerShellExecutionService StateRequestService = UniversalDashboard.Services.StateRequestService
22:17:57 [Debug] PowerShellExecutionService ConnectionId =
22:17:57 [Debug] PowerShellExecutionService SessionId =
22:17:57 [Debug] PowerShellExecutionService ArgumentList =
22:17:57 [Debug] PowerShellExecutionService UDPage =
22:17:57 [Warn] ComponentController RunScript() La valeur ne peut pas être null.
Nom du paramètre : key
   à System.Collections.Concurrent.ConcurrentDictionary`2.ContainsKey(TKey key)
   à UniversalDashboard.Services.SessionManager.GetSession(String id)
   à UniversalDashboard.Execution.PowerShellExecutionService.ExecuteEndpoint(ExecutionContext context, AbstractEndpoint endpoint)
   à System.Threading.Tasks.Task`1.InnerInvoke()
   à System.Threading.Tasks.Task.Execute()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à UniversalDashboard.Execution.PowerShellExecutionService.<ExecuteEndpointAsync>d__11.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à UniversalDashboard.Execution.ExecutionService.<ExecuteEndpointAsync>d__2.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à UniversalDashboard.Controllers.ComponentController.<RunScript>d__8.MoveNext()
22:17:57 [Info] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker Executed action UniversalDashboard.Controllers.ComponentController.GetEndpoint (UniversalDashboard) in 52.1372ms
22:17:57 [Info] Microsoft.AspNetCore.Session.DistributedSession Session started; Key:40c47064-6934-d5d9-5a09-47a1bb8e5995, Id:0b02321b-2e4d-f811-8467-8abcbef51ee6
22:17:57 [Error] Microsoft.AspNetCore.Server.Kestrel Connection id "0HLRST59FBONP", Request id "0HLRST59FBONP:00000007": An unhandled exception was thrown by the application.
22:17:57 [Info] Microsoft.AspNetCore.Hosting.Internal.WebHost Request finished in 57.2466ms 500
Invoke-RestMethod : Le serveur distant a retourné une erreur : (500) Erreur interne du serveur.
Au caractère Ligne:1 : 1
+ Invoke-RestMethod -Uri $uri -Method GET -Headers @{ Authorization = " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation : (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

PS C:\Users\Lx\GitPerso>

Ah, interesting. I’ll have to put in a fix for that. That’s a bug

1 Like

I’ll get it into tonight’s nightly build.

1 Like

do you htink this can solve my https problem ? ok so your nighlty will be available sometime tomorrow for me xD i’ll test it then and keep you informed !

Sorry. I realizd I didn’t include the correct test. Can you actually run this one: https://github.com/ironmansoftware/universal-dashboard/blob/master/src/UniversalDashboard.UITest/Integration/Https.Tests.ps1

With start-uddashboard it’s working. (i did not use pester, but copied the code … anyway ! )

But if i use start-udrestapi

PS C:\Users\Lx\GitPerso> $Dashboard = Start-UDRestApi -Port 10001 -Certificate $Cert
PS C:\Users\Lx\GitPerso> $Dashboard

Name        Port Running DashboardService
----        ---- ------- ----------------
Dashboard1 10001    True UniversalDashboard.Services.DashboardService


PS C:\Users\Lx\GitPerso> Enable-UDLogging
PS C:\Users\Lx\GitPerso> 22:54:56 [Info] Microsoft.AspNetCore.Server.Kestrel Connection id "0HLRSU6Q16QDL" bad request data: "Invalid request line: ''"

sorry the above was run using POSTMAN …

EDIT:
Used PS, so ok maybe i should not use invoke-webrequest

PS C:\Users\Lx\GitPerso>  $Request = Invoke-WebRequest https://localhost:10001/dashboard
23:23:59 [Info] Microsoft.AspNetCore.Server.Kestrel Connection id "0HLRSU6Q16QDP" bad request data: "Invalid request line: ''"
23:23:59 [Info] Microsoft.AspNetCore.Server.Kestrel Connection id "0HLRSU6Q16QDQ" bad request data: "Invalid request line: ''"
Invoke-WebRequest : La connexion sous-jacente a été fermée : Une erreur inattendue s'est produite lors de l'envoi.
Au caractère Ligne:1 : 13
+  $Request = Invoke-WebRequest https://localhost:10001/dashboard
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation : (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

La connexion sous-jacente a été fermée : Une erreur inattendue s’est produite ==> the underlying session was closed …

Me, too.
Reverted to 2.6.2.

1 Like

Ah! That’s the ticket. Thanks. I’ll look into it.

1 Like

ok cool :slight_smile: if you want me to test anything dont hesitate!
I see you dont have tests for the start-udrestapi (or maybe i did not see them) do you want me to write it ? this can be done pretty fast as you i just have to replace start-uddashboard with start-udrestapi. Dunno if this can be useful … !

I can write the test when I look at it today. Thanks for the offer though!

I’ve got a PR that fixes this. It will be merged today: https://github.com/ironmansoftware/universal-dashboard/pull/1362

2 Likes

Thanks adam ! when can we get the fix for UD Enterprise ? i tried last nightly but it did not fix!

Sorry. Fix didn’t get merged to enterprise until today. My fault.

1 Like