We are adding logging into our APIs and want to find out how many times a specific API was hit. The current $URL variable includes the URL and the URL Param ("/api/ad/groupmembers/automation") which makes finding out how many times a specific API was hit difficult (if not impossible).
Is it possible to have a Static URL Parameter? ("/api/ad/groupmembers/:groupname")
This data already exists in the Management API:
Product: PowerShell Universal
This currently isn’t included as a variable in the APIs. I can get that added.
This will be available in 2.3.0:
SessionId = $SessionId
ConnectionId = $ConnectionId
RequestId = $RequestId
UrlDefinition = $UrlDefinition
Awesome! What’s the difference between $SessionID and $ConnectionId?
That’s actually a good question. I believe the session ID is used to identify user session data stored with the server. That ID is retrieved from the session manager. Session info is maintained via cookies. The connection ID is used to track a single user through the HTTP by using correlation headers. I think they pretty much track a user in two different ways.
Some more information here about correlation IDs: ASP.NET Core Correlation IDs - Steve Gordon - Code with Steve
Ok, interesting. So if we wanted to log who is calling the API would you think $ConnectionId or $SessionId would be better? We also were looking at the $Identity variable but that only works if the API has Authorization enabled
Might depend on the HTTP client but cookies (session ID) might be more automatic. The correlation header (connection ID) might depend on the client passing the headers along whenever they receive them.