Here’s a sample PUT request that creates an HCP namespace named Accounts-Receivable for the Finance tenant. The namespace definition is in an XML file named AccountsRecNS.xml. The request is made using a tenant-level user account that includes the administrator role.
Request body in XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<namespace>
<name>Accounts-Receivable</name>
<description>Created for the Finance department at Example Company by Lee
Green on 2/9/2017.</description>
<hashScheme>SHA-256</hashScheme>
<enterpriseMode>true</enterpriseMode>
<hardQuota>50 GB</hardQuota>
<softQuota>75</softQuota>
<servicePlan>Short-Term-Activity</servicePlan>
<optimizedFor>CLOUD</optimizedFor>
<versioningSettings>
<enabled>true</enabled>
<prune>true</prune>
<pruneDays>10</pruneDays>
</versioningSettings>
<multipartUploadAutoAbortDays>10</multipartUploadAutoAbortDays>
<searchEnabled>true</searchEnabled>
<indexingEnabled>true</indexingEnabled>
<customMetadataIndexingEnabled>true</customMetadataIndexingEnabled>
<customMetadataValidationEnabled>true</customMetadataValidationEnabled>
<replicationEnabled>true</replicationEnabled>
<allowErasureCoding>true</allowErasureCoding>
<readFromReplica>true</readFromReplica>
<serviceRemoteSystemRequests>true</serviceRemoteSystemRequests>
<tags>
<tag>Billing</tag>
<tag>lgreen</tag>
</tags>
</namespace>
Request with cURL command line
curl -k -iT AccountsRecNS.xml -H "Content-Type: application/xml"
-H "Authorization: HCP bGdyZWVu:a3b9c163f6c520407ff34cfdb83ca5c6"
"https://finance.hcp.example.com:9090/mapi/tenants/finance/namespaces"
Request in Python using PycURL
import pycurl
import os
filehandle = open("AccountsRecNS.xml", 'rb')
curl = pycurl.Curl()
curl.setopt(pycurl.HTTPHEADER, ["Content-Type: application/xml",
"Authorization: HCP \
bGdyZWVu:a3b9c163f6c520407ff34cfdb83ca5c6"])
curl.setopt(pycurl.URL,
"https://finance.hcp.example.com:9090/mapi/tenants/finance/" +
"namespaces")
curl.setopt(pycurl.SSL_VERIFYPEER, 0)
curl.setopt(pycurl.SSL_VERIFYHOST, 0)
curl.setopt(pycurl.UPLOAD, 1)
curl.setopt(pycurl.INFILESIZE, os.path.getsize("AccountsRecNS.xml"))
curl.setopt(pycurl.READFUNCTION, filehandle.read)
curl.perform()
print curl.getinfo(pycurl.RESPONSE_CODE)
curl.close()
filehandle.close()
Request headers
PUT /mapi/tenants/finance/namespaces HTTP/1.1
Host: finance.hcp.example.com:9090
Authorization: HCP bGdyZWVu:a3b9c163f6c520407ff34cfdb83ca5c6
Content-Type: application/xml
Content-Length: 1197
Response headers
HTTP/1.1 200 OK
X-HCP-SoftwareVersion: 9.0.0.2
Content-Length: 0
© 2015, 2020 Hitachi Vantara LLC. All rights reserved.