How to get all records from a zone through the API

How to get all records from a zone through the API

Getting a snapshot of the DNS domain definition is important for IT auditing, when you want to save the zone as part of CI, or just for backup. 

This is a 4 step process, examples are for curl

Step 0: Setup
To work around curl problems with escaping command line special characters, create a text file containing JSON like this 
{ "customer\_name" : "ACME" , "user\_name" : "user", "password" : "secretpassword" }
For our sample, lets call this file Credentials.txt

step 1: get the session token.
You have to POST your credentials to <https://api2.dynect.net/REST/Session/> like this:

curl -X POST -d @Credentials.txt -H "Content-Type: application/json" <https://api2.dynect.net/REST/Session/>

This returns a JSON response that looks like this: 

{"status": "success",
  "data": {"token": "6WQpNcFBN......wkAvtSvzzIkZaMQ==", "version": "3.5.4"}, 
  "job\_id": 670441930,
  "msgs": [{"INFO": "login: Login successful", "SOURCE": "BLL", "ERR\_CD": null, "LVL": "INFO"}]}

step 2: Assign a variableParse the response, get the value of "token: and assign the value of "token" to the TOKEN variable.  

step 3: List records in a domain
Next is a GET command, that expects JSON, and uses a custom header with the Auth token

curl -X GET -H "Content-Type: application/json" -H "Auth-Token: $TOKEN" <https://api2.dynect.net/REST/AllRecord/mydomain.com/>