Fail when request is unauthorized

This commit is contained in:
Petri Asikainen 2021-12-18 11:49:27 +02:00
parent ec40912018
commit e2923cade8

View file

@ -144,6 +144,10 @@ function Invoke-SnipeitMethod {
# This could be handled nicely in an function such as:
# ResolveError $response -WriteError
Write-Error $($webResponse.messages | Out-String)
} elseif ( $webResponse.StatusCode -eq 'Unauthorized') {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] An Unauthorized response was received"
Write-Error "Cannot connect to Snipe It: Unauthorized."
return $false
} else {
#update operations return payload
if ($webResponse.payload) {