Here’s a sample POST request that packages system logs for download. The command requests to package logs between the dates of 8/19/2015 and 8/21/2015. The dates are specified in an XML file named logPrepare.xml. The request is made using a system-level user account that includes the administrator role.
Request body in XML
<?xml version=1.0" encoding="UTF-8" standalone="yes"?>
<logPrepare>
<startDate>08/19/2015</startDate>
<endDate>08/21/2015</endDate>
</logPrepare>
Request with cURL command line
curl -X POST -d @logPrepare.xml -k -i -H "Content-type: application/xml" -H "Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382" https://admin.hcp.example.com:9090/mapi/logs/prepare
Request in Python using PycURL
import pycurl
import os
filename = "logPrepare.xml"
filehandle = open(filename, "rb")
filesize = os.path.getsize(filename)
curl = pycurl.Curl()
curl.setopt(pycurl.VERBOSE, True)
curl.setopt(pycurl.CUSTOMREQUEST, "POST")
curl.setopt(pycurl.READFUNCTION, filehandle.read)
curl.setopt(pycurl.HTTPHEADER, ["Content-Type: application/xml", \
"Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"])
curl.setopt(pycurl.URL, "https://admin.hcp.example.com:9090/mapi/logs/prepare")
curl.setopt(pycurl.SSL_VERIFYPEER, False)
curl.setopt(pycurl.SSL_VERIFYHOST, False)
curl.setopt(pycurl.UPLOAD, 1)
curl.setopt(pycurl.INFILESIZE, filesize)
curl.perform()
filehandle.close()
curl.close()
Request headers
POST /mapi/logs/prepare HTTP/1.1
User-Agent: curl/7.27.0
Host: admin.hcp.example.com:9090
Accept: */*
Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382
Content-Type: application/xml
Content-Length: 56
Response headers
HTTP/1.1 200 OK
X-HCP-SoftwareVersion: 7.2.0.589
Content-Length: 0
© 2016 Hitachi Data Systems Corporation. All rights reserved.