Hi guys,
I’m not able to translate the following command-line to Powershell:
curl -X GET -H “Content-Type: application/json” -H “X-Access-Key: <token>” -d ‘{“report_time”:“monthly”,“report_type”:“summary”,“month”:“4”,“account_id”:“91ea5bd5cdc04adb9f5e3c00a346c463”}’ ‘https://<zios-address>:8443/api/zios/usage_reports/generate.json’
The problem is how to translate the parameter “-d” to the Powershell.
Could you help me please?
Thanks!
The Invoke-RestMethod equivalent of curl’s -d is the body parameter. I think the equivalent will be this but obviously I can’t check it works:
$param = @{
Uri = 'https://<zios-address>:8443/api/zios/usage_reports/generate.json'
Headers = @{X-Access-Key = "<token>"}
Content-Type = "application/json"
Body = @{
report_time = "monthly";
report_type = "summary";
month = "4";
account_id = "91ea5bd5cdc04adb9f5e3c00a346c463"
}
Method = 'Post'
}
Invoke-RestMethod @param
Good reference guide here: