Idea: PSUendpoints in separate scripts

Product: PowerShell Universal
Version: 2.7.4

This question might be a bit out in left field but I had an idea.

My endpoints.ps1 contains roughly 15 endpoints for various things, some which are quiet lengthy scripts. Would it make sense to break these endpoints out into their own file?

I tend to manage my endpoints via the script itself since editing it from the UI causes the formatting to get all wonky.

We added a -Path parameter to New-UDEndpoint for this reason in 2.10 (April release). You won’t be able to manage this from the UI but if you are using the file directly anyways, you’ll be able to just specify a path and have multiple files for your endpoints.

New-UDEndpoint -URL /test -Method GET -Path test.ps1

Then test.ps1 would be.

"Hello, world!"
4 Likes

What is the difference between New-PSUEndpoint and New-UDEndpoint?

That was a mistype. It’s New-PSUEndpoint

New-PSUEndpoint -Url "/testjob" -Path ".\Repository\Job.ps1" -Method GET

Invoke-RestMethod : The remote server returned an error: (404) Not Found.

Does the script have to be registered under ..\Repository\.universal\scripts.ps1 ?

No but I think the path is scoped to the repo directory already.

New-PSUEndpoint -Url "/testjob" -Path "Job.ps1" -Method GET

Still returning a 404…

Other endpoints are still working though.

Are you seeing any errors in the notification window? It doesn’t seem to be picking up the configuration.

Yeah adding the following to the bottom of my endpoints.ps1

New-PSUEndpoint -Url "/testjob" -Path "Job.ps1" -Method GET

I get the following

Ah. Yeah, this was added in 2.10 so you would need a nightly build. Sorry that wasn’t clear. This will be released in the April release.

That was my mistake. I misread that as 2.1…

Thanks for taking time to check this out.

1 Like