Merge pull request #253 from PetriAsi/fix/#252

Fail when request is unauthorized
This commit is contained in:
Petri Asikainen 2021-12-18 12:24:29 +02:00 committed by GitHub
commit 7ac8a5c9bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -144,6 +144,10 @@ function Invoke-SnipeitMethod {
# This could be handled nicely in an function such as: # This could be handled nicely in an function such as:
# ResolveError $response -WriteError # ResolveError $response -WriteError
Write-Error $($webResponse.messages | Out-String) 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 { } else {
#update operations return payload #update operations return payload
if ($webResponse.payload) { if ($webResponse.payload) {