Skip to content

API functional testing

amplifi edited this page Jun 29, 2017 · 1 revision

Command line using HTTPie

You need to install the Python httpie package. Then you can do:

http POST https://platform-staging.cadasta.org/api/v1/account/login/ username=<whatever> password=<whatever>

You'll get a response with an authentication token. You can then make other requests using this, by saying things like

http GET https://platform-staging.cadasta.org/api/v1/organizations/
http POST https://platform-staging.cadasta.org/api/v1/organizations/ Authorization:"Token <token-value>" name="My Test Org"

The things in the command line introduced with a colon go into HTTP headers, and the things introduced with an equals sign go into the POST body as fields in a JSON object.

In Chrome, using PostMan

This ought to be an easier option, but I'm having a hard time getting the current version to work... Maybe someone else wants to write some notes?

Django Rest Framework's GUI

You can test individual endpoints using a browser interface. To access the GUI, type the URL of the endpoint into your browser's address field.

The interface uses session authentication. To authenticate a request with a user you need to log the user in via the standard login form of the platform.

Clone this wiki locally