Author Posts

March 12, 2015 at 5:03 am

Can anyone advise why invoke-restmethod would not return error information when run within the -action {} block of a filesystemwatcher?

I've tried using specific error variables and error actions, but I cannot get it to generate anything.

March 12, 2015 at 5:51 am

To be more specific, when invoke-restmethod is called outside the filesystemwatcher -action {} block, I get the following error (which is what I want to see)

Invoke-RestMethod : Cannot create record.Invalid term for this field.00.000000
At line:1 char:1
+ Invoke-RestMethod -uri " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

...but inside the action script block, I get nothing.

I am not interested in why I'm getting the error, only that I should get an error when there is a problem with the call.