Calling Rest Route internally

Is there a way to call a route internally in a REST API route ??

I want a “global” route to make calls to other routes internally …

at the moment i’m doing something like that:

$Test = New-UDEndpoint -Url "/Test/:id" -Method POST -Endpoint {

$Global = New-UDEndpoint -Url "/Global/:id" -Method POST -Endpoint {
    ## it's working, but it feels weird :) 
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    $a = Invoke-RestMethod -Method Post "https://myserver/api/test/someID" -Body '{"id":$id}'

    ## do some stuff

Is there another way to do this without using invoke-restmethod ?

Not really. But one thing you could do is create a module with a function that the endpoints call and put the functionality that you would put in your global endpoint and then call the function from both endpoints.

1 Like

Thank you adam :slight_smile: