This fix attempts to alleviate the issue of unexpected 503 errors when making SDK calls in larger scripts which results in errors or incomplete datasets being returned. We have added a do-while loop with a counter to the API call function that will detect if a 503 error is present, wait a period of time and then re-attempt the call until either the call is successful or the max counter is reached.
Is there anything particularly tricky?
503 errors are inherently unreliable and difficult to test for. We can manually test this by replacing the lookup for a 503 error with a more replicable error, such as 400 (Bad Request).
How should this be tested?
Find a SDK function that is suitable for testing, ex: Get-JCSdkUserAssociation
Within the process block, look for the line that contains If ($JCHttpResponse.Result.StatusCode -eq 503) and replace the 503 with 400.
Issues
What does this solve?
This fix attempts to alleviate the issue of unexpected 503 errors when making SDK calls in larger scripts which results in errors or incomplete datasets being returned. We have added a do-while loop with a counter to the API call function that will detect if a 503 error is present, wait a period of time and then re-attempt the call until either the call is successful or the max counter is reached.
Is there anything particularly tricky?
503 errors are inherently unreliable and difficult to test for. We can manually test this by replacing the lookup for a 503 error with a more replicable error, such as 400 (Bad Request).
How should this be tested?
Get-JCSdkUserAssociation
If ($JCHttpResponse.Result.StatusCode -eq 503)
and replace the503
with400
.Import-Module '/Users/USER/Documents/GitHub/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.V2/JumpCloud.SDK.V2.psd1' -force
Get-JCSdkUserAssociation -UserID '6120152163f8976f332dafc' -target active_directory
UserID
is not the correct length, therefore will always fail