filesystemwatcher and invoke-restmethod

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of RPW888 RPW888 1 year, 9 months ago.

  • Author
    Posts
  • #23257
    Profile photo of RPW888
    RPW888
    Participant

    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.

  • #23259
    Profile photo of RPW888
    RPW888
    Participant

    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 "http://127.0.0.1/blah/blah ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + 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.

You must be logged in to reply to this topic.