目前我正在嘗試使用正在使用cURL的API,並試圖將其轉換爲PowerShell。如何在PowerShell中正確使用發佈請求
目前由該公司給出的是使用捲曲的例子是:
$ curl -X POST -u "youruser:yourkey" -H "Content-Type: application/json"
"https://falconapi.crowdstrike.com/detects/entities/summaries/GET/v1" -d
'{"ids": ["ldt:ddaab9931f4a4b90450585d1e748b324:148124137618026"]}'
現在我想通過使用Invoke-WebRequest的方法使用PowerShell中轉換下面這樣的:
Invoke-WebRequest -Method Post -Uri $site -Body -Credential 'whatever credentials' |
ConvertFrom-Json | Select -ExcludeProperty resources
我越來越糊塗上的部分是如何格式化 - 身體的要求是類似的東西:
'{"ids": ["ldt:ddaab9931f4a4b90450585d1e748b324:148124137618026"]}'
其中的LDT部分是我正在通過一個數組,所以而不是ldt我試圖調用一個變量,如$檢測,但我無法。