API Endpoint Organization

Product: PowerShell Universal
Version: 3.9.5

Morning all,

I’m building a bit of a caching management system so if I don’t need up to date live data from say AD, Exchange, Graphs, etc I can call it from the PSU cache making it a lot quicker.

Everything is working flawlessly the way I have set it up (Scripts that run under triggers / schedules to keep the cached data container up to date). but I’m trying to build some end points now, a set that goes and grabs live data from different services and one that grabs the data from PSU Cache.

So I started creating them like this:

<URL>/Get/AD/:ADUser
<URL>/Get/AD/:ADComputer
<URL>/Get/AD/:ADMembership
<URL>/Get/EXO/:Mailbox
<URL>/Get/MG/:MGUser

<URL>/**CacheGet**/:ADUser
<URL>/**CacheGet**/:ADComputer
.... Etc etc etc.

Seen my issue yet? haha.
If I call /Get/AD/COMPUTERNAME it will call the ADUser EndPoint.

The only reason I am doing it like this is because I really like the ‘Folder View’ for organization. Is there a way to do it so I can organize it like above without having 100’s of different folders containing a single EndPoint in each or is this just not a good way to go about this in general?

image

Thanks for any help!

Hi, @Intee ! Judging from your second screenshot, this is a REST issue, not specifically a PowerShell Universal issue. REST uses the URI as the means of identifying how to route requests. If you have two endpoints with the same URI, that both use the same verb (e.g. GET), but two different variables at the end of the URI, the middleware that routes your request won’t be able to determine which endpoint to route your request to. In the example you’ve provided, the biggest error is that PowerShell Universal isn’t preventing you from making two endpoints using the same verb and URI. I recommend filing a bug here: GitHub - ironmansoftware/issues: Public Issue tracker for Ironman Software products. or contacting support.

1 Like