sailpoint-oss / powershell-sdk

PowerShell Module for accessing SailPoint IdentityNow APIs
https://developer.sailpoint.com/
MIT License
20 stars 15 forks source link

API Request / Response Payload Logging at Verbose #6

Closed rob-buskens-sp closed 1 year ago

rob-buskens-sp commented 1 year ago

While API request / response logging in non-prod environments is undesirable it can be very helpful when exploring / developing.

$DebugPreference = 'Continue' : $Search = @{ indices = @('identities') query = @{ query = 'pat.smith' } sort = @( 'id' ) } Invoke-PaginateSearch -Increment 50 -Limit 100 -Search $Search -Verbose :

Log output DEBUG: ReturnType SearchDocument[] DEBUG: IsBodyNullable False DEBUG: Calling Endpoint: https://company2825-poc.api.identitynow-demo.com/v3/search DEBUG: Getting Access Token DEBUG: https://company2825-poc.api.identitynow-demo.com/oauth/token DEBUG: DEBUG: DEBUG: Token Exp: 03/12/2023 22:07:28 DEBUG: Token is valid VERBOSE: HTTP/1.1 POST with 404-byte payload VERBOSE: Retrying after interval of 5 seconds. Status code for previous attempt: BadRequest

In the above we can see the search URL (context is unclear) and URL used for the authorization, and that the token is valid. So far so good.

There isn't any visibility into how the SDK converted the provided data into the API calls.

We do see information in the exception:

{"detailCode":"400.1.0 Required data missing or empty","trackingId":"7e8b3213dbb441208d62f9ff6557e135","messages":[{"locale":"und","localeOrigin":"REQUEST","text":"At least one of the fields \"query, aggregations\" must be specified."},{"locale":"en-US","localeOrigin":"DEFAULT","text":"At least one of the fields \"query, aggregations\" must be specified."}],"causes":[]}

As a query field was specified... something appears to be getting mucked up along the way to calling the search.

have the full IDN API Request request / response info would provide insight, perhaps at the VERBOSE level. headers, body, etc. Could be as raw as the Postman console view.

tyler-mairose-sp commented 1 year ago

Hello @rob-buskens-sp, I added some additional logging at the verbose level. This will include the request headers and body sent to the API endpoint. This is added in https://github.com/sailpoint-oss/powershell-sdk/pull/21.