Welcome › Forums › General PowerShell Q&A › Translate CURL command-line to Powershell
- This topic has 2 replies, 2 voices, and was last updated 2 weeks, 6 days ago by
Participant.
Viewing 2 reply threads
-
AuthorPosts
-
-
December 22, 2020 at 3:53 pm #281939
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!
-
December 23, 2020 at 7:02 am #282056
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:
PowerShell1234567891011121314$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 @paramGood reference guide here:
PowerShell1-
This reply was modified 4 weeks ago by
Matt Bloomfield. Reason: Formatting
-
This reply was modified 4 weeks ago by
-
December 30, 2020 at 2:34 pm #283339
Great! It’s working!
Thank you Matt!
-
-
AuthorPosts
Viewing 2 reply threads
- You must be logged in to reply to this topic.