Bonjour,
Dans le cadre d'une migration, je constate que la commande curl est un alias du cmdlet Invoke-Webrequest.
J'ai une commande cURL qui utilise un proxy et différents champs de formulaire.
J'essaye de transposer cela avec la commande powershell :Code:curl -v https://monurl:443/Buyer/filedownload?realm=USERNAME -w "https" -F "from=$FROMDATEVALUE" -F "to='$TODATEVALUE'" -F "sharedsecret=XXXXX" -F "event=Export DATA"* -F clienttype="curl" -o "C:\chemin_vers_mon_path\Export.zip"'
Code:
1
2
3
4
5
6
7
8
9
10
11
12 $url="https://URL:443/Folders/filedownload?realm=USERNAME" $body = @{ from="$FROMDATEVALUE"; to="$TODATEVALUE"; sharedsecret="XXXXXX"; event="Export Documents"; clienttype="curl"; } $ExportFile="Export.zip" Invoke-WebRequest -Method Post -Uri $url -proxy http://10.135.0.29:8080 -body $body -OutFile $ExportFile
Cela me génère une erreur 500 côté serveur, je pense que j'ai un problème de format de ma commande.
Code:
1
2
3
4
5
6
7 Invoke-WebRequest : The remote server returned an error: (500) Internal Server Error. At D:\pathtomypowershell_ps1\ps_2.ps1:25 char:1 + Invoke-WebRequest -Method Post -Uri $url -proxy http://IPPROXY:8080 -body $b ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand