I need to write a PowerShell script, which deletes DNS record from Softlayer cloud, using Softlayer REST API.
The below command should do my purpose. I have $headers
correctly setup. My issue is with $uri
and $jsonObject
.
Invoke-WebRequest -Uri $uri -Headers $headers -Method POST -ContentType application/json -Body $jsonObject
can anybody please give me an example of values for $jsonObject
and $uri
?
Should $uri
be like below? If yes, what is the Object.json
, do I need to define it?
$uri = "https://api.service.softlayer.com/rest/v3.1/SoftLayer_Dns_Domain_ResourceRecord/deleteObject/Object.json"
I found how: $uri="https://api.softlayer.com/rest/v3/SoftLayer_Dns_Domain/$domainID/getResourceRecords.json"
Below will return a json file which has all records in our domain: Invoke-WebRequest -Uri $uri -Headers $headers -Method GET -ContentType application/json
From received json file ,we can extract record ID ($recordID in below) of the record that we want to delete and then run below: $deleteResoutceURI= "https://api.softlayer.com/rest/v3/SoftLayer_Dns_Domain_ResourceRecord/$recordID/deleteObject.json"
Invoke-WebRequest -Uri $deleteResoutceURI -Headers $headers -Method POST -ContentType application/json