How to test the API with Postman

Z√úRICH - Daniel,Schmid posted on 9. Oktober 2014
The  Worldbox API is stateless. Means each request has to be authenticated against an APIKey and an APIsecret send in the request-header. Therefore the API can not be tested over a browser by just adding the resource URL in the URL-bar.

Fortunatly there is a very nice chrome-extension called "Postman" which helps to test and saves a lot of time. "Postman is a powerful HTTP client to help test web services easily and efficiently. Postman lets you craft simple as well as complex HTTP requests quickly. It also saves requests for future use so that you never have to repeat your keystrokes ever again." Postman can be downloaded from the chrom app store or form their website.

I did a postman collection for the resources with have so far on the API (can be downloaded at the end). A collection is a set of requests with demo data and parameters.


The left sidebar shows the content of the collection "Worldbox v.1.1 Test".
 

Environment

The collection is a setup to be used in different environments. API "stage" should be used to test the API! It routes all request to  http://api.stage.worldbox.ch/
If you later on like to do a quick test on the production server, the only thing to do is to change the environment from "stage" to "production".  The environment can be choosen on top right corner. 

Authentication 

Postman makes authentication very easy. Click on "Basic Auth" that is the authentication schema we use on the Worldbox API. Than add the APIsecret as USERNAME and the APIkey as PASSWORD. Click "Refresh Header" and postman saves credentials together with the request data. This has to be done for ALL requests only once.  
 

Send Request

For each request you can edit the request data and play around with them. All GET-request will retrieve a response according to the resource URL and query-parameters.



A bit tricky is the "Place Order" request since it uses a string representation of JSON orderequest object. Just click "send" and the request will send to the API. The two post requests send data over the API and enter the data into the order database.


Response 

In The response text area shows the result in JSON-notation. In the example below the returned data for a "Company Information" request.



Download Collection

The collectionfile below  can imported into postman and is ready to use. 
WorldboxAPI%20v.1-Test.postman_collection.zip

Further Information

-