Example: Retrieving a list of eligible local candidates

Content Platform Tenant Management Help

Version
9.7.x
File Size
4269 KB
Audience
anonymous
Part Number
MK-95HCPH002-19

Here’s a sample GET request that retrieves a list of the HCP tenants and default-namespace directories on the local system, hcp-ma.example.com, that are eligible to be included in the active/active replication link named MA-CA. The request writes the list of local candidates to a file named local-candidates.xml. The request is made using a system-level user account that includes the administrator role.

Request with cURL command line

curl -k -i -H "Accept: application/xml"
    -H "Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"
    "https://admin.hcp-ma.example.com:9090/mapi/services/replication/links/
         MA-CA/localCandidates?prettyprint" > local-candidates.xml

Request in Python using PycURL

import pycurl
filehandle = open("local-candidates.xml", 'wb')
curl = pycurl.Curl()
curl.setopt(pycurl.HTTPHEADER, ["Accept: application/xml",
  "Authorization: HCP \
  YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"])
curl.setopt(pycurl.URL,
  "https://admin.hcp-ma.example.com:9090/mapi/services/" +
  "replication/links/MA-CA/localCandidates?prettyprint")
curl.setopt(pycurl.SSL_VERIFYPEER, 0)
curl.setopt(pycurl.SSL_VERIFYHOST, 0)
curl.setopt(pycurl.WRITEFUNCTION, filehandle.write)
curl.perform()
print curl.getinfo(pycurl.RESPONSE_CODE)
curl.close()
filehandle.close()

Request headers

GET /mapi/services/replication/links/MA-CA/localCandidates?prettyprint HTTP/1.1
Host: admin.hcp-ma.example.com:9090
Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382
Accept: application/xml

Response headers

HTTP/1.1 200 OK
Content-Type: application/xml
X-HCP-SoftwareVersion: 9.0.0.2
Content-Length: 330

Response body in XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<content>
    <defaultNamespaceDirectories>
        <name>brochures_2015</name>
        <name>brochures_2016</name>
        <name>brochures_2017</name>
    </defaultNamespaceDirectories>
    <tenants>
        <name>Finance</name>
        <name>HR</name>
        <name>Sales-Mktg</name>
    </tenants>
</content>