Skip to content

Commit d6e7c52

Browse files
committed
Standardize result object keys in API client scripts
Replaces 'severity' with 'state' and 'message' with 'resultText' in result objects for Invoke-ExecApiClient.ps1 and Invoke-ExecUpdateRefreshToken.ps1. Also updates error handling in Invoke-ExecUpdateRefreshToken.ps1 for consistency.
1 parent 24c462e commit d6e7c52

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecApiClient.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function Invoke-ExecApiClient {
148148
if (!$Client) {
149149
$Results = @{
150150
resultText = 'API client not found'
151-
severity = 'error'
151+
state = 'error'
152152
}
153153
} else {
154154
$ApiConfig = New-CIPPAPIConfig -ResetSecret -AppId $Request.Body.ClientId -Headers $Request.Headers

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecUpdateRefreshToken.ps1

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Invoke-ExecUpdateRefreshToken {
1+
function Invoke-ExecUpdateRefreshToken {
22
<#
33
.FUNCTIONALITY
44
Entrypoint,AnyTenant
@@ -49,16 +49,21 @@ Function Invoke-ExecUpdateRefreshToken {
4949
$TenantName = $request.body.tenantId
5050
}
5151
$Results = @{
52-
'message' = "Successfully updated the credentials for $($TenantName). You may continue to the next step, or add additional tenants if required."
53-
'severity' = 'success'
52+
'resultText' = "Successfully updated the credentials for $($TenantName). You may continue to the next step, or add additional tenants if required."
53+
'state' = 'success'
5454
}
5555
} catch {
56-
$Results = [pscustomobject]@{'Results' = "Failed. $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.message)"; severity = 'failed' }
57-
}
56+
$Results = [pscustomobject]@{
57+
'Results' = @{
58+
resultText = "Failed. $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.message)"
59+
state = 'failed'
60+
}
61+
}
5862

59-
return ([HttpResponseContext]@{
60-
StatusCode = [HttpStatusCode]::OK
61-
Body = $Results
62-
})
63+
return ([HttpResponseContext]@{
64+
StatusCode = [HttpStatusCode]::OK
65+
Body = $Results
66+
})
6367

68+
}
6469
}

0 commit comments

Comments
 (0)