locked
Invoke-WebRequest -Form Parameter Not Supported? RRS feed

  • Question

  • Hi all!

    (Bear with me; I'm a newbie to Powershell!)

    My issue is that I'm trying to use the Invoke-WebRequest command, and all looks well when I typed things in, but I'm getting the error:

    Invoke-WebRequest : A parameter cannot be found that matches parameter name 'Form'.
    At line:1 char:160
    + ... .json" -Headers @{ Authorization=("Bearer " + $token) } -Form @{ "imp ...
    + ~~~~~
    + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

    ...which implies that the -Form parameter doesn't exist, and though I see the parameter in the MS Docs documentation for Invoke-WebRequest at https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-6, but the interesting part is that when I ran get-help for the Invoke-WebRequest command, I got...

    PS C:\Users\misterfresh\desktop\integration_test> get-help -Name Invoke-WebRequest

    NAME
        Invoke-WebRequest

    SYNTAX
        Invoke-WebRequest [-Uri] <uri>[-UseBasicParsing] [-WebSession <webrequestsession>] [-SessionVariable <string>] [-Credential <pscredential>] [-UseDefaultCredentials] [-CertificateThumbprint <string>] [-Certificate <x509certificate>] [-UserAgent <string>] [-DisableKeepAlive] [-TimeoutSec <int>] [-Headers <idictionary>] [-MaximumRedirection <int>] [-Method {Default | Get | Head | Post | Put | Delete | Trace | Options | Merge | Patch}] [-Proxy <uri>] [-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-Body <object>] [-ContentType <string>] [-TransferEncoding {chunked | compress | deflate | gzip | identity}] [-InFile <string>] [-OutFile <string>] [-PassThru] [<commonparameters>]

    ...Notice that there's no -Form parameter listed, thus my problem, but I'm not sure why there is a -Form in the Docs online but no -Form in my Powershell. Anybody got any clues on this issue?

    --- Fresh



    • Edited by Mister Fresh Wednesday, January 30, 2019 8:48 PM
    Wednesday, January 30, 2019 8:43 PM

Answers

  • What version of PowerShell are you running, the link to the docs looks like for version 6

    $PSVersionTable
    Looking at that document, that parameter is only available in PS v 6. When you switch to other versions that parameter is not available.


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''


    • Edited by clayman2 Wednesday, January 30, 2019 8:48 PM typo
    • Marked as answer by Mister Fresh Wednesday, January 30, 2019 8:50 PM
    Wednesday, January 30, 2019 8:46 PM

All replies

  • What version of PowerShell are you running, the link to the docs looks like for version 6

    $PSVersionTable
    Looking at that document, that parameter is only available in PS v 6. When you switch to other versions that parameter is not available.


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''


    • Edited by clayman2 Wednesday, January 30, 2019 8:48 PM typo
    • Marked as answer by Mister Fresh Wednesday, January 30, 2019 8:50 PM
    Wednesday, January 30, 2019 8:46 PM
  • Ah! That seems to be just the issue. I'm running 5.1.x. I'll get this thing updated.

    Many thanks, clay!

    Wednesday, January 30, 2019 8:50 PM