Skip to content

Commit e2923ca

Browse files
committed
Fail when request is unauthorized
1 parent ec40912 commit e2923ca

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

SnipeitPS/Private/Invoke-SnipeitMethod.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ function Invoke-SnipeitMethod {
144144
# This could be handled nicely in an function such as:
145145
# ResolveError $response -WriteError
146146
Write-Error $($webResponse.messages | Out-String)
147+
} elseif ( $webResponse.StatusCode -eq 'Unauthorized') {
148+
Write-Verbose "[$($MyInvocation.MyCommand.Name)] An Unauthorized response was received"
149+
Write-Error "Cannot connect to Snipe It: Unauthorized."
150+
return $false
147151
} else {
148152
#update operations return payload
149153
if ($webResponse.payload) {

0 commit comments

Comments
 (0)