I have a command in CURL which returns data. I tried to translate it to PowerShell or VBS, but I couldn't get any data and I have no error message in my code.
Following is my CURL command :
$Data = curl "http://www.boursorama.com/ajax/ui/refresh.phtml/boursorama/block/bourse/derives/search/turbos?" -H "X-Requested-With: XMLHttpRequest" -H "X-Brs-Xhr-Request: true" --data "class=Boursorama_Block_Bourse_Derives_Search_Turbos" --compressed
Following is my Powershell command :
$hash =@{
"class" = "Boursorama_Block_Bourse_Derives_Search_Turbos"
}
$JSON = $hash | ConvertTo-Json
$R = Invoke-WebRequest -Method Post -URI "http://www.boursorama.com/ajax/ui/refresh.phtml/boursorama/block/bourse/derives/search/turbos?" -Headers @{"X-Brs-Xhr-Request"="true"} -Body $JSON -ContentType “application/json”
$R.Content
Following is my VBS command :
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
strJSONToSend = "{""class"": ""Boursorama_Block_Bourse_Derives_Search_Turbos""}"
xmlhttp.open "POST","http://www.boursorama.com/ajax/ui/refresh.phtml/boursorama/block/bourse/derives/search/turbos?",False
xmlhttp.setRequestHeader "X-Brs-Xhr-Request", "true"
xmlhttp.send strJSONToSend
xmlhttp.responseText
I have a last issue, I'm trying to send a parameter "page" but the result is the same with different page number.
Following is the PowerShell command :
$Data = Invoke-WebRequest -Method Post -URI "http://www.boursorama.com/ajax/ui/refresh.phtml/boursorama/block/bourse/derives/search/turbos?page=2" -Headers @{"X-Brs-Xhr-Request"="true";"X-Requested-With" = "XMLHttpRequest"} -body @{"class"="Boursorama_Block_Bourse_Derives_Search_Turbos";"parameters[page]"="2"}
I don't know if the parameter has to be sent in the URL or in the body.