I am trying to get help on converting my curl request to powershell code. what I am not getting is how to pass the parameter to url in invoke-restmethod call.

My curl request:

curl --compressed -k -v -u user_redacted:password_redacted https://analysiscenter.veracode.com/api/4.0/getbuildlist.do -F app_id=123456 > 20190419BuildList.xml 

Powershell request:

$user = "user_redacted"
$pass= "password_redacted"
$pair = "$($user):$($pass)"
$Folder = "C:\VeraCode" 
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($Pair))
$headers = @{ Authorization = "Basic $encodedCredentials" }
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-RestMethod -Method Get -Headers $headers -Uri 'https://analysiscenter.veracode.com/api/4.0/getbuildlist.do -F app_id=123456' -OutFile $Folder\GetAppBuildList_$(get-date -f yyyy-MM-dd).xml

Can anybody help me how do pass the variable app_id in the powershell request as it was throwing me below error:

Invoke-RestMethod : The remote server returned an error: (404) Not Found.

Please advise.

  • 2
    Something like -Body @{ app_id = '123456' } while removing the ` -F app_id=123456` from the Uri string? – JosefZ Apr 19 '19 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.