WebAPI Reference Guide > Generic Request/Response Format > Request Format

Request Format

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:

http://example.com:10081/ZendServer/Api/<ACTION>

All HTTP requests must include the following HTTP headers:

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:

Refer to specific method documentation for a list of required and optional parameters.

Examples

Usage Example

The following is an example of a call to the (obviously fake) “makePizza” method (some lines are broken for readability):

POST /ZendServer/Api/makePizza HTTP/1.1
Host: zscm.local

Date: Sun, 11 Jul 2010 13:16:10 GMT

User-agent: Zend_Http_Client/1.10
Accept: application/vnd.zend.serverapi+xml;version=1.0

X-Zend-Signature: bob.at.example.com;
7f0db29a3d82a81ec6f5387f5aae96e295530b4c8acf2074488185902dc900f4
Content-type: application/x-www-form-urlencoded
Content-length: 100
style=thinCrust&extraCheese=TRUE&extras%5B0%5D=pepperoni&extras%5B1%5D=onion&extras%5B2%5D=pineapple

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:

GET /ZendServer/Api/getPizzaStatus?pizzaId=53 HTTP/1.1
Host: zscm.local|
Date: Sun, 11 Jul 2010 13:16:10 GMT
User-agent: Zend_Http_Client/1.10
Accept: application/vnd.zend.serverapi+xml;version=1.0
X-Zend-Signature: bob.at.example.com;
02dcbf4cb338a0a8b807c83a84a7888929f5c06491105d6752f290da47a24619

Notice that the ‘pizzaId’ parameter is passed as part of the URL’s query string.

 

 

 

Related Links

Related Links:

Response Format

 

 

 

© 1999-2013 Zend Technologies, Ltd. All rights reserved.