Example: Start log packaging
Here’s a sample POST request that packages system logs for download. The command requests to package logs between the dates of 8/19/2017 and 8/21/2017. 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/2017</startDate> <endDate>08/21/2017</endDate> </logPrepare>
Request with cURL command line
curl -iX 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 Host: admin.hcp.example.com:9090 Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382 Content-Type: application/xml Content-Length: 56
Response headers
HTTP/1.1 200 OK X-HCP-SoftwareVersion: 9.0.0.2 Content-Length: 0