DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1
headers = {
'Content-Type': "text/plain",
'Accept': "*/*",
'Cache-Control': "no-cache",
'Host': "s-platform.api.opendns.com",
'Accept-Encoding': "gzip, deflate",
'Connection': "keep-alive",
'cache-control': "no-cache"
}
response = requests.request(
"POST",
url,
data=json.loads(payload),
headers=headers,
params=querystring)
print(response.text)

Once domains are placed in the list, a customer can get
the list of the domains by using the GET method for
https://s-platform.api.opendns.com/1.0/domains
endpoint. Example 11-4 shows an example of a simple
Python requests method.


Example 11-4 Python GET Request to List Domains
Using the Enforcement API


Click here to view code image


""" List domains using the Enforcement API """
import requests
url = "https://s-
platform.api.opendns.com/1.0/domains"
querystring = {"customerKey":"XXXXXXX-YYYY-
ZZZZ-YYYY-XXXXXXXXXXXX"}
response = requests.request("POST", url,
headers=headers, params=querystring)
print(response.text)

Example 11-5 shows the response to the GET from
Example 11-4. The answer is a JSON response with a
meta tag that describes the page number, the limit, and
pointers to the previous and next pages.

Free download pdf