Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Add a variable in a Invoke-RestMethod

$
0
0

Hello guys I need your help:

I would like to pass a variable in the $body of my command :

$name = "test.com."
$headers = @{"X-API-Key" = 'myApiKey'
}
$body = '{"rrsets": [ {"name": '+ $name +', "type": "CNAME", "ttl": 600, "changetype": "REPLACE", "records": [ {"content": "things.com.", "disabled": false } ] } ] }'
Invoke-RestMethod -Method Patch -Uri https://dnsadmin.ovea.com/api.com -Headers $headers -ContentType "application/json" -Body $body 

As you can see I try to add the $name variable but it's obviously not the good method, I don't find the correct way to do it.

Does someone have a solution for me ?

Thanks for your time.


 

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>