PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,859 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to use this Curl example and make it work with Powershell. I am stuck at multiple data for "Identifier". this section will create report in CSV format
"report_metadata": {
"report_type": "orders",
"columns": [
{
"identifier": "order_id"
},
{
"identifier": "order_status"
},
{
"identifier": "serial_number"
},
{
"identifier": "account_id"
},
{
"identifier": "request_state"
},
{
"identifier": "product_name"
},
{
"identifier": "order_created_date"
},
{
"identifier": "additional_email"
How can I create JSON body in Powershell?
I try
$body = @{identifier = "order_id";"common_name";"sans"};
but it wont like it.
Thanks
Hi,
The ConvertTo-Json cmdlet converts an object to a JSON-formatted string. https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-7.5
Please note that duplicate keys are not allowed in hash tables.
$body = @{identifier1 = "order_id"; identifier2 = "common_name"; identifier3 = "sans"}
$jsonstring= $body | ConvertTo-Json
Best Regards,
Ian Xue
If the Answer is helpful, please click "Accept Answer" and upvote it.