Equivalent notation for Curl -d option

I am looking to automate the Check_MK api.

From the documentation they are using linux examples and I am trying to translate to the example into a powershell context:


curl "http://myserver/mysite/check_mk/webapi.py?action=get_host&_username=automation&_secret=myautomationsecret&output_format=json&request_format=json" -d 'request={"hostname":"myserver123"}'

This is just one example.

-d 'request={"hostname":"myserver123"}'

I thought i might send it json

$body= new-object -TypeName psobject -Property @{
    hostname= "server"

 $overarchingobject| Add-Member -Name attributes -Value $body -MemberType NoteProperty
$json =$overarchingobject | ConvertTo-Json
Invoke-RestMethod -uri $url  -Body $body -Method post -Verbose

However the website doesnt seem to recognise the syntax that I give it.


Any help appreciated as to what is the equivalent format for curl -d in powershell. Thanks in advance :slight_smile:

You have to pass $json as its is the converted content to post and the key name is request in curl the example not attributes

$body = new-object -TypeName psobject -Property @{
    hostname = "server"

$overarchingobject| Add-Member -Name request-Value $body -MemberType NoteProperty
$json = $overarchingobject | ConvertTo-Json
Invoke-RestMethod -uri $url  -Body $json  -Method post -Verbose