The request format defines the required format for each request sent to Zend Server. The request format for all Zend Server Web API requests are formatted as described in this page, regardless of the specific method used.
Request Method, URL, and Headers
Web API HTTP requests use HTTP GET for read-only API calls, and HTTP POST for all state changing API calls.
The request URL is different for each action, and is in one of the following formats:
- Zend Server - Where <ACTION> is the action to perform (e.g. “disableServer”):
All HTTP requests must include the following HTTP headers:
- Date - Contains the current date and time in the GMT time zone, in the format specified by the HTTP RFC for date fields (e.g. “Wed, 07 Jul 2010 17:10:55 GMT”). This value is used to verify the authenticity of the request, and is expected to be in sync with the server time (within 30 seconds).
- User-agent - The user agent string is logged by the server and used for message authenticity verification. It cannot be empty.
- Host - The HTTP host header is expected to be present and is used for message authenticity verification.
- X-Zend-Signature - The API key name and calculated request signature which is used to authenticate and validate the request. See Authentication and Message Verification for additional information on calculating the signature.
In addition, you should send the Accept HTTP request header to designate your supported API version(s). If the Accept header is missing, the server will fall back to the default API version. This is described in detail in API Versioning Negotiation.
For POST requests, including any parameters or payload, clients must set the Content-type header to either "application/x-www-form-urlencoded" or "multipart/form-data", depending on the payload. You must specify the size of the request body as required by the HTTP/1.1 protocol, that is by using the Content-length header, the Content-transfer-encoding: chunked header or simply by closing the connection.
Passing Request Parameters
API methods that require passing parameters may be passed in the following forms:
- For GET requests, parameters are passed in the URL query part (following the ‘?’) in a URL-encoded format, similar to how HTML forms sent using the GET method are encoded.
- For POST requests, parameters should be passed in the request body, encoded using either the "application/x-www-form-urlencoded" (as specified by the HTML 4.01 standard) or "multipart/form-data" (as specified in RFC-2388) encoding methods.
- For some methods (namely methods that may transfer large amounts of binary data), the ‘multipart/form-data’ encoding method must be used.
Refer to specific method documentation for a list of required and optional parameters.
The following is an example of a call to the (obviously fake) “makePizza” method (some lines are broken for readability):
The request above is for the “makePizza” method, with the following parameters: style, extraCheese, extras.
The following example shows a call to a read-only “getPizzaStatus” method:
Notice that the ‘pizzaId’ parameter is passed as part of the URL’s query string.