Problem with Invoke-Restmethod in a script

Product: PowerShell Universal
Version: 3.9.8

I need to create several small webapps to display data from restpoints on our identity management system. First app is a password generator which works from powershell:

PS C:\Users\skikacoroski> Invoke-RestMethod -Uri $url -Authentication “Basic” -Credential $cred

However, when I run it as a script or add it to a dashboard or page in Powershell Universal I get:

[error] An attempt was made to access a socket in a way forbidden by its access permissions.

My goal is to have a page that users can just refresh to get a different set of passwords. Any ideas or hints to get around this problem would be most helpful.

Just to clarify, I have Invoke-Restmethod in a script. The script is used as a datasource for a table. If I comment out the Invoke-Restmethod and create an object with some passwords in it, the page works mostly well. Only problem is it works, but I get “Failed to load the data source for this page. Make sure that the API or script is returning data.” Not sure why that is happening.

Upgraded to 4.02 and it is working now.