Difference between revisions of "Horizon/RESTAPI"
(→GET requests) |
(→Testing) |
||
Line 7: | Line 7: | ||
=== Testing === | === Testing === | ||
− | To Test the Horizon REST APIs using POSTMAN (Chrome Plugin) | + | To Test the Horizon REST APIs using POSTMAN (Chrome Plugin), login normally going to the exact API address (or localhost) that you'll use from POSTMAN. Once you've logged in your browser will have an access cookie that it'll pass on with all its requests. |
− | |||
− | |||
==== GET requests ==== | ==== GET requests ==== | ||
Line 23: | Line 21: | ||
| X-Requested-With || XMLHttpRequest | | X-Requested-With || XMLHttpRequest | ||
|} | |} | ||
+ | |||
+ | The GET requests should include a csrftoken cookie (eg. csrftoken=onXnBfMqIxuFGr437P91Uuxdl09t2ykQ). You should copy this off if you need to perform any POST requests. | ||
==== POST requests ==== | ==== POST requests ==== | ||
− | Input the URL. | + | Input the URL. |
+ | |||
+ | For exampleː http://127.0.0.1:8005/api/nova/keypairs/ | ||
Set the following headers | Set the following headers | ||
Line 36: | Line 38: | ||
| Content-Type || application/json | | Content-Type || application/json | ||
|- | |- | ||
− | | X-CSRFToken || | + | | X-CSRFToken || the value of the csrftoken cookie you've seen in any GET request to the same address |
|} | |} | ||
Revision as of 06:00, 19 February 2015
Horizon REST API
Horizon has a REST API that allows client side code to make API through the Horizon server without DJANGO server side rendering. This is to support the angular work being done in Horizon. It takes care of issues like cross origin resource scripting as well as leveraging authentication and authorization libraries already in existence.
THE API ARE FOR THE EXCLUSIVE USE OF HORIZON DEVELOPMENT AND ARE NOT SUPPORTED FOR EXTERNAL USE AT THIS TIME
Testing
To Test the Horizon REST APIs using POSTMAN (Chrome Plugin), login normally going to the exact API address (or localhost) that you'll use from POSTMAN. Once you've logged in your browser will have an access cookie that it'll pass on with all its requests.
GET requests
Input the URL.
For exampleː http://127.0.0.1:8005/api/glance/images
Set the following header:
Header | Value |
---|---|
X-Requested-With | XMLHttpRequest |
The GET requests should include a csrftoken cookie (eg. csrftoken=onXnBfMqIxuFGr437P91Uuxdl09t2ykQ). You should copy this off if you need to perform any POST requests.
POST requests
Input the URL.
For exampleː http://127.0.0.1:8005/api/nova/keypairs/
Set the following headers
Header | Value |
---|---|
X-Requested-With | XMLHttpRequest |
Content-Type | application/json |
X-CSRFToken | the value of the csrftoken cookie you've seen in any GET request to the same address |
Set the raw content as JSON formatted.
Exampleː
{ "name":"foo" }