cURL no PowerShell - Tabela de hash dupla em --data?
Estou tentando (e falhando há horas) converter esse script cURL no PowerShell:
curl -X POST \
https://example.net \
-H 'Authorization: Bearer 1234567890' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"data": {
"MID": 33,
"DID": "66666666",
"CID": 10002,
"status": "ACTIVE",
"HID": "11"
}
}'
script do My PowerShell se parece com isso - suspeito que tenha algo a ver com a tabela de hash dupla que criei em $ Body, mas estou realmente perdid
.. script cortado por simplicidade
$Body = @{
'data'= @{
'MID'= 33;
'DID'= "66666666";
'CID'=10002;
'status'="ACTIVE";
'HID'= "11"
}
}
$CurlArgument = '-X', 'POST',
'https://example.net',
'-H', 'Authorization: Bearer 1234567890',
'-H', 'Content-Type: application/json',
'-d',
$Body
$CURLEXE = 'C:\Windows\System32\curl.exe'
& $CURLEXE @CurlArgument
Recebo a seguinte mensagem de erro ao executar:
..."message":"Access not allowed","details":{"5011":"A JSONObject text must begin with '{' at 1 [character 2 line 1]"}}]}
Experimentei adicionar depois de $ Body:
| ConvertTo-Json
mas isso me dá este erro:
Unexpected character ('d' (code 100)): was expecting double-quote to start field name
minha variável $ CurlArgument se parece com a mesma (que é o primeiro script cURL):
-X
POST
https://example.net
-H
Authorization: Bearer 1234567890
-H
Content-Type: application/json
-d
{
"data": {
"CID": 10002,
"MID": 33,
"HID": "11",
"DID": "66666666",
"status": "ACTIVE"
}
}
omo sempre, a assistência seria muito apreciad