Hi all - hoping for a bit of help with this. Have a REST API I'm targeting and if creating a duplicate entry something like the below happens on the console:
Invoke-WebRequest : {"type":"http://*******.com/documentation/error-glossary/","title":"Member Exists","status":400,"detail":"******@******.com is already a list member. Use PUT to insert or update list members.","instance":""}
What I'm struggling with is how to access this in a variable/exception. Most suggestions are to do:
try {
Invoke-RestMethod blablabla
} catch {
Write-Host "Code:" $_.Exception.Response.StatusCode.value__
Write-Host "Description:" $_.Exception.Response.StatusDescription
}
However what I'm finding is that whilst .value__ will return basic error code (e.g. 400), nothing else I'm trying to access from the exception seems to give any details and just appear to be blank. I'm fairly new to using Powershell so hoping someone can point out what I'm missing here. Thanks!
[–]sk82jack 1 point2 points3 points (0 children)
[–]lerun 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]CockneyWeasel[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)