The purpose of this tutorial is to demonstrate how to perform the following updates to a zone called example.com:
A zone may be updated through the following steps:
Prerequisites
The prerequisites for this tutorial are listed below.
The reader should have basic working knowledge on how to submit a request to our REST API service.
The Route (DNS) feature must:
Contain a primary zone.
This primary zone will be updated upon the completion of this tutorial.
Almost all requests to our REST API services require authorization. Authorization is granted by passing a REST API token via the Authorization request header using the following syntax:
Copy your REST API token from the Web Service REST API Token section of the My Settings page.
If the Web Service REST API Token section is not present on the My Settings page, then you are not authorized to access our REST API services. Please contact your CDN administrator to gain access.
The first step is retrieving the zone that will be updated. Zone retrieval may be performed through the Get Zone endpoint.
Update the highlighted text and then perform the following GET request:
The response body for the above request will look similar to the following:
{ "Comment" : "", "DomainName" : "example.com.", "FailoverGroups" : [], "LoadBalancingGroups" : [], "Records" : { "A" : [{ "Name" : "www", "Rdata" : "155.11.22.33", "TTL" : 3600 }, { "Name" : "www2", "Rdata" : "155.11.22.44", "TTL" : 3600 } ], "AAAA" : [], "CNAME" : [], "MX" : [], "NS" : [], "SPF" : [], "SRV" : [], "TXT" : [] }, "Status" : 1, "Version" : 1409100239, "ZoneId" : 1000, "ZoneType" : 1 }
Records may be added and deleted from a zone by inserting and deleting them from the Records object. Notice the following two changes to zone data:
Change | Relevant Code |
---|---|
An A record called "www2" has been deleted. |
Lines 11 - 15 from the sample code provided above. |
A CNAME record called "cdn" has been added. |
Lines 14 - 18 from the sample code provided below. |
Most zone data can be updated by simply adding, modifying, or deleting the desired field data from the zone. Exceptions to this rule are reserved fields which cannot be modified. These fields are: DomainName, Version, ZoneId, and ZoneType.
{
"Comment" : "",
"DomainName" : "example.com.",
"FailoverGroups" : [],
"LoadBalancingGroups" : [],
"Records" : {
"A" : [{
"Name" : "www",
"Rdata" : "155.11.22.33",
"TTL" : 3600
}
],
"AAAA" : [],
"CNAME" : [{
"Name" : "cdn",
"Rdata" : "wpc.0001.edgecastcdn.net.",
"TTL" : 3600
}
],
"MX" : [],
"NS" : [],
"SPF" : [],
"SRV" : [],
"TXT" : []
},
"Status" : 1,
"Version" : 1409100239,
"ZoneId" : 1000,
"ZoneType" : 1
}
The final step is to set the above zone data as the request body of the Update Zone endpoint.
Update the highlighted text and then perform the following PUT request:
Make sure to set the request body to the zone data updated in step 2 (as shown below).
{
"Comment" : "",
"DomainName" : "example.com.",
"FailoverGroups" : [],
"LoadBalancingGroups" : [],
"Records" : {
"A" : [{
"Name" : "www",
"Rdata" : "155.11.22.33",
"TTL" : 3600
}
],
"AAAA" : [],
"CNAME" : [{
"Name" : "cdn",
"Rdata" : "wpc.0001.edgecastcdn.net.",
"TTL" : 3600
}
],
"MX" : [],
"NS" : [],
"SPF" : [],
"SRV" : [],
"TXT" : []
},
"Status" : 1,
"Version" : 1409100239,
"ZoneId" : 1000,
"ZoneType" : 1
}
The response to the above request provides confirmation that the above zone data has been successfully submitted. This response should be an exact match for the submitted zone data with the exception of the Version parameter which will be incremented to reflect that zone data has been updated.