Connect-PSUServer : Response could not be deserialized to JSON: GET https://universal.companyname.com/api/v1/accessible

Product: PowerShell Universal
Version: 3.9.7

Ever since I’ve deployed Universal to Azure as standard WebApp, I’ve been receiving this error when running Connect-PSUServer, either manually or when connecting automatically from VSCode extension.

Connect-PSUServer : Response could not be deserialized to JSON: GET https://universal.companyname.com/api/v1/accessible
At line:1 char:1
+ Connect-PSUServer -ComputerName 'https://universal.companyname.com' -App ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-PSUServer], FlurlParsingException
    + FullyQualifiedErrorId : Flurl.Http.FlurlParsingException,UniversalAutomation.ConnectServerCommand

This error has been a thing since 3.9.4 and also happens when trying the new v4 release.
I’ve yet to figure out what the cause is.

Has anyone else seen this error, perhaps?

@ruben The only time I’ve seen this is when there’s an error with API token. I had this happen after I turned on app token security, then tried to use a token that was generated via the -GrantAppToken parameter of a dashboard. However, this error was fixed in version 3.9.6. With the containers/Azure web app, is there a way to check the PowerShell Universal Logs to see if it has logged an error at the same time as the connection?

Interesting info, thanks for sharing!

At this moment, app token security (Enhanced App Token Security) is disabled and the tokens I’ve tried (with the same result) are the standard one that is created on installation and one that is bound to my identity, created from within the Admin UI.

I’ll try and enable the Enhanced App Token Security and generate a new App Token to see if it changes anything.

The Universal Logs unfortunately do not show anything related to this behavior on any of the settings (informational, debug, warning etc).

Unfortunately, no change :frowning:

The interesting part of it all is that everything seems to be functioning flawlessly. It’s just the error on connecting, that’s it. I think.

What happens when you do this?

Invoke-WebRequest https://universal.companyname.com/api/v1/accessible -Headers @{
    Authorization = "Bearer <apptoken>"
}
StatusCode        : 200
StatusDescription : OK
Content           : {"mode":"Server","username":"ruben@companyname.com","oneWayGitSync":false,"manualGitMode":false,"roles":["Administrator"],"builtInRole":true,"accessControls":{"scripts":31}}
RawContent        : HTTP/1.1 200 OK
                    Content-Type: application/json; charset=utf-8
                    Date: Mon, 03 Jul 2023 14:10:25 GMT
                    Set-Cookie: ARRAffinity= <dont-think-i-should-share-this>;Path=/;Htt...
Forms             : {}
Headers           : {[Content-Type, application/json; charset=utf-8], [Date, Mon, 03 Jul 2023 14:10:25 GMT], [Set-Cookie, 
                    <dont-think-i-should-share-this>;Path=/;HttpOnly;SameSite=None;Secure;Domain=universal.companyname.com], 
                    [Server, Microsoft-IIS/10.0]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 167

Weird. Looks like a valid response to me.

If you change it to Invoke-Restmethod, does it deserialize properly?

Invoke-RestMethod https://universal.companyname.com/api/v1/accessible -Headers @{
    Authorization = "Bearer <apptoken>"
}
mode           : Server
username       : ruben@companyname.com
oneWayGitSync  : False
manualGitMode  : False
roles          : {Administrator}
builtInRole    : True
accessControls : @{scripts=31}

Sure does!

Hmmm. And you’re just calling Connect-PSUServer like this?

Connect-PSUServer -ComputerName https://universal.companyname.com -AppToken <token>

Yep, either manually or automatically upon launching the VSCode extension:

Connect-PSUServer -ComputerName 'https://universal.companyname.com' -AppToken '<my-app-token>'
Connect-PSUServer : Response could not be deserialized to JSON: GET https://universal.companyname.com/api/v1/accessible
At line:1 char:1
+ Connect-PSUServer -ComputerName 'https://universal.companyname.com' -App ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-PSUServer], FlurlParsingException
    + FullyQualifiedErrorId : Flurl.Http.FlurlParsingException,UniversalAutomation.ConnectServerCommand

Freshly copied from the PowerShell Extension console session in my VSCode instance.

Interesting find;
It does not do that in a regular PowerShell console, outside of VSCode.

Should’ve checked that earlier…

Scrap that. Same behaviour, regardless of where I run the Connect-PSUServer command…
In terminal, standalone CLI or through VSCode… As admin, as non-admin…


Issue no longer occurs since 3.9.11 and 4.0.5

Don’t know what changed, but good job! :smiley:

Hi @ruben ,

Does this still work for you?

I am having the exact same problem with version 4.0.9 when trying to get the VSCode extension working.

I’ve been hesitant with updating our environment since V4 has been introduced so currently I’m on 3.9.15 still.
The issue is not present for me on 3.9.15