API HTTP Response

Product: PowerShell Universal
Version: 4.2.21

I am playing around with monitoring our APIs using a standard monitoring system.

To test this i created a new API, and inserted this code:

New-PSUApiResponse -StatusCode 500

When i then executed “curl -I http://server:5000/api/v1/status”, i got a HTTP 200 response:
HTTP/1.1 200 OK
Date: Fri, 31 May 2024 12:09:06 GMT
Server: Kestrel

How can i change the HTTP response code, that will be returned to the client?

That is a reserved route for load balancing… a 200 says that the service is up and running. Loading of endpoints should probably block loading duplicate routes like that if that is really what is going on.

For all of your stuff you should steer clear of using anything with /api/, especially /api/v1/. /api/v1/* is used for the admin API routes…

1 Like