Example: Listing content properties
Here is a sample metadata query API request that lists the content properties for all indexed objects in the medical namespace owned by the employees tenant. The query uses an XML request body and requests results in XML format.
Request body in the XML file named MedicalQuery.xml
<queryRequest> <object> <query>namespace:medical.employees</query> <count>0</count> <contentProperties>true</contentProperties> </object> </queryRequest>
Request with cURL command line
curl -i -k -H "Authorization: HCP bXl1c2Vy:3f3c6784e97531774380db177774ac8d" -H "Content-Type: application/xml" -H "Accept: application/xml" -d @MedicalQuery.xml "https://employees.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://employees.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("MedicalQuery.xml", 'rb') curl.setopt(pycurl.UPLOAD, 1) curl.setopt(pycurl.CUSTOMREQUEST, "POST") curl.setopt(pycurl.INFILESIZE, os.path.getsize("MedicalQuery.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: employees.example.com Authorization: HCP bXl1c2Vy:3f3c6784e97531774380db177774ac8d Content-Type: application/xml Accept: application/xml Content-Length: 155
Response headers
HTTP/1.1 200 OK Transfer-Encoding: chunked
XML response body
To limit the example size, the XML below shows only two contentProperty
entries in the response body.
<?xml version='1.0' encoding='UTF-8'?> <queryResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/static/xsd/query-result-7.0.xsd"> <query> <expression>namespace:medical.employees</expression> </query> <resultSet /> <status totalResults="0" results="0" message="" code="COMPLETE" /> <contentProperties> <contentProperty> <name>DocDateOfBirth</name> <expression>/record/doctor/dob</expression> <type>DATE</type> <multivalued>false</multivalued> <format>MM/dd/yyy</format> </contentProperty> <contentProperty> <name>DocLastName</name> <expression>/record/doctor/name/lastName</expression> <type>STRING</type> <multivalued>false</multivalued> <format></format> </contentProperty> </contentProperties> </queryResult>