Example: Checking for replication collisions
Here is a sample metadata query API request that checks whether any namespaces owned by the europe tenant currently contain objects that are flagged as replication collisions. The response to the query does not include operation records for any of those objects, but the status of INCOMPLETE indicates that records for such objects exist.
The query uses an XML request body and requests results in XML format.
Request body in the XML file named ReplicationCollisions.xml
<queryRequest> <operation> <count>0</count> <systemMetadata> <replicationCollision>true</replicationCollision> <transactions> <transaction>create</transaction> </transactions> </systemMetadata> </operation> </queryRequest>
Request with cURL command line
curl -i -k -H "Authorization: HCP bXl1c2Vy:3f3c6784e97531774380db177774ac8d" -H "Content-Type: application/xml" -H "Accept: application/xml" -d @ReplicationCollisions.xml "https://europe.hcp.example.com/query?prettyprint"
Request in Python using PycURL
import pycurl import os curl = pycurl.Curl() # Set the URL, command, and headers curl.setopt(pycurl.URL, "https://europe.hcp.example.com/" + "query?prettyprint") curl.setopt(pycurl.SSL_VERIFYPEER, 0) curl.setopt(pycurl.SSL_VERIFYHOST, 0) curl.setopt(pycurl.POST, 1) curl.setopt(pycurl.HTTPHEADER, ["Authorization: HCP bXl1c2Vy:3f3c6784e97531774380db177774ac8d", "Content-Type: application/xml", "Accept: application/xml"]) # Set the request body from an XML file filehandle = open("ReplicationCollisions.xml", 'rb') curl.setopt(pycurl.UPLOAD, 1) curl.setopt(pycurl.CUSTOMREQUEST, "POST") curl.setopt(pycurl.INFILESIZE, os.path.getsize("ReplicationCollisions.xml")) curl.setopt(pycurl.READFUNCTION, filehandle.read) curl.perform() print curl.getinfo(pycurl.RESPONSE_CODE) curl.close() filehandle.close()
Request headers
POST /query?prettyprint HTTP/1.1 Host: europe.hcp.example.com Content-Type: application/xml Accept: application/xml Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382 Content-Length: 233
Response headers
HTTP/1.1 200 OK Transfer-Encoding: chunked
XML response body
<?xml version='1.0' encoding='UTF-8'?> <queryResult xmlns:xsi="http://www.w3.org/2019/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/static/xsd/query-result-9.0.xsd"> <query start="0" end="1395694699683" /> <resultSet /> <status results="0" message="" code="INCOMPLETE" /> </queryResult>