none
Positional parameter cannot be found RRS feed

  • Question

  • I am attempting to update data on a remote url using PUT but keep getting this error:

    Error***:  System.Management.Automation.ParameterBindingException: A positional parameter cannot be found that accepts argument '{
        "hasAccess":  true,
        "facilityId":  "02"
    }'.
       at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
       at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

    I have verified with the vendor that this is the correct format they are expecting the "body" in. So I am not sure what is causing the error.

    This is the command line I am using:

    $userfacupd = Invoke-WebRequest -Headers @{'Authorization' = 'Bearer ' + $token} -Method PUT $BodyFac $URL_UpdateUserFac

    Tuesday, December 24, 2019 1:41 PM

Answers

  • I figured it out. I was missing the -Body before $BodyFac.
    • Marked as answer by J-Bal Tuesday, December 24, 2019 4:11 PM
    Tuesday, December 24, 2019 4:11 PM

All replies

  • Is  '$BodyFac $URL_UpdateUserFac' part of your Invoke-WebRequest command. if yes then you should use Parameter name first then pass variable name.

    Tuesday, December 24, 2019 1:56 PM
  • I figured it out. I was missing the -Body before $BodyFac.
    • Marked as answer by J-Bal Tuesday, December 24, 2019 4:11 PM
    Tuesday, December 24, 2019 4:11 PM