How to use the curl command in PowerShell?

后端 未结 2 1988
温柔的废话
温柔的废话 2020-11-30 08:46

Am using the curl command in PowerShell to post the comment in bit-bucket pull request page through a Jenkins job. I used the below PowerShell command to execut

相关标签:
2条回答
  • 2020-11-30 09:29

    Use splatting.

    $CurlArgument = '-u', 'xxx@gmail.com:yyyy',
                    '-X', 'POST',
                    'https://xxx.bitbucket.org/1.0/repositories/abcd/efg/pull-requests/2229/comments',
                    '--data', 'content=success'
    $CURLEXE = 'C:\Program Files\Git\mingw64\bin\curl.exe'
    & $CURLEXE @CurlArgument
    
    0 讨论(0)
  • 2020-11-30 09:36

    In Powershell 3.0 and above there is both a Invoke-WebRequest and Invoke-RestMethod. Curl is actually an alias of Invoke-WebRequest in PoSH. I think using native Powershell would be much more appropriate than curl, but it's up to you :).

    Invoke-WebRequest MSDN docs are here: https://technet.microsoft.com/en-us/library/hh849901.aspx?f=255&MSPPError=-2147217396

    Invoke-RestMethod MSDN docs are here: https://technet.microsoft.com/en-us/library/hh849971.aspx?f=255&MSPPError=-2147217396

    0 讨论(0)
提交回复
热议问题