I’ve created a PSUEndpoint (with a routing parameter):
New-PSUEndpoint -Url “/test/:param1” -Endpoint {
param(
$param1=‘test’
)
New-PSUApiResponse -StatusCode 200 -Body “Param1: ‘$param1’”
}
If I call this endpoint with Invoke-Restmethod -Uri 'http://psu.domain.local/test/parameter47 it works perfect returning “Param1: ‘parameter47’”.
If I call this endpoint with Invoke-Restmethod -Uri ‘http://psu.domain.local/test’ it doesn’t work (returning 404 not found).
Is it possible to default a routing parameter, so that I can call it without the routing parameter? The best I’ve found was to add a second endpoint (without the routing parameter) to call the endpoint with the routing parameter with the default value. But this adds some extra effort, like returning the result of the endpoint with the routing parameter and “doubling” the error handling.
Thanks
Roland