Example: Enabling advanced downstream DNS configuration
Here’s a sample POST request that sets the downstream DNS mode to advanced. The DNS mode is specified in an XML file named network.xml. The request is made using a system-level user account that has the administrator role.
Request body in XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <networkSettings> <downstreamDNSMode>ADVANCED</downstreamDNSMode> </networkSettings>
Request with cURL command line
curl -k -i -d @network.xml -H "Content-Type: application/xml" -H "Authorization: HCP YWRtaW4=:e00cf25ad42683b3df678c61f42c6bda" "https://admin.hcp.example.com:9090/mapi/network"
Request in Python using PycURL
import pycurl import os filehandle = open("network.xml", 'rb') curl = pycurl.Curl() curl.setopt(pycurl.HTTPHEADER, ["Content-Type: application/xml", / "Authorization: HCP YWRtaW4=:e00cf25ad42683b3df678c61f42c6bda"]) curl.setopt(pycurl.URL, "https://admin.hcp.example.com:9090/mapi/network" curl.setopt(pycurl.SSL_VERIFYPEER, 0) curl.setopt(pycurl.SSL_VERIFYHOST, 0) curl.setopt(pycurl.CUSTOMREQUEST, "POST") curl.setopt(pycurl.UPLOAD, 1) curl.setopt(pycurl.INFILESIZE, os.path.getsize("network.xml")) curl.setopt(pycurl.READFUNCTION, filehandle.read) curl.perform() print curl.getinfo(pycurl.RESPONSE_CODE) curl.close() filehandle.close()
Request headers
POST /mapi/network?downstreamDNSMode=ADVANCED HTTP/1.1 Host: admin.hcp.example.com:9090 Authorization: HCP YWRtaW4=:e00cf25ad42683b3df678c61f42c6bda Content-Type: application/xml Content-Length: 141
Response headers
HTTP/1.1 200 OK X-HCP-SoftwareVersion: 9.0.0.2 Content-Length: 0