You use the HTTP POST method to send a metadata query API request to HCP. The POST request for both object-based and operation-based queries has these elements:
- A request URL.
- Optionally, if the URL starts with an IP address, an HTTP Host header.
- An Authorization header.
- An HTTP Content-Type header with one of these values:
- If the request body is XML, application/xml
- If the request body is JSON, application/json
- An HTTP Accept header to specify the response format: application/xml or application/json.
- Optionally, to send the query in gzip-compressed format:
- An HTTP Content-Encoding header with a value of gzip
- A chunked transfer encoding
Note: When using cURL to send the query in gzip-compressed format, the request must specify --data-binary. If the request specifies -d instead, HCP returns a 400 (Bad Request) error. - Optionally, to request that HCP return the response in gzip-compressed format, an HTTP Accept-Encoding header containing the value gzip or *. The header can specify additional compression algorithms, but HCP uses only gzip.
- Optionally, to request that HCP format the returned XML or JSON in an easily readable format, a prettyprint URL query parameter. The prettyprint parameter increases the time it takes to process a request. Therefore, you should use it only for testing purposes and not in production applications.
- A request body containing the query criteria and specifications for the contents of the result body. The entries you can specify depends on whether the request body is for an object-based query or an operation-based query.
- A request returns a 413 response code if the request exceeds the 8K Content-Length body limit.