translating curl request to invoke-restmethod

Looking for some assistance on translating this curl request to powershell. I’ve tried a couple different ways of submitting the body but everything seems to spit back an error. Here’s a successful curl request :

curl --request PATCH  --header 'Authorization2: key'  --header "Content-Type: application/json"  --data '{ "count":"1" }'  https://website ; echo 

And here’s basically what I’ve been doing in powershell:

$uri = "https://website" $header = @{ Accept = 'application/json' Authorization2 = 'key' } $body = @{count="1"} Invoke-RestMethod -Method Patch $uri -Headers $header -Body $body 

The error that gets thrown on the invoke command is :

Invoke-RestMethod : {"error": "request contains invalid json body."} 

Not totally sure what I’m missing here but maybe someone has a keener eye on what I’m doing wrong.

submitted by /u/cmdub-
[link] [comments]

Leave a Reply