ABF API

From Rosalab Wiki
Revision as of 11:15, 20 June 2014 by D uragan (Talk | contribs) (Created page with "== ABF REST API == In order to operate with ABF, one can use REST API - that is, ABF server is able to accept commands and provide you with repsonces by menas of HTTP request...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

ABF REST API

In order to operate with ABF, one can use REST API - that is, ABF server is able to accept commands and provide you with repsonces by menas of HTTP requests.

Detailed API description is available at the ABF-DOC site.

Utilizing ABF API by means if Curl

ABF API is primarily intended to be used in different programs that need to access ABF server. In particular, API is used in the ABF console client, so if you need to perform some actions at ABF server from your command line, it is more convinent to use ABF console client.

However, it is possible that the console client doesn't allow to perform some action (e.g., they are just not implemented), though there is an API request for that action. In this case, you can utilize corresponding API by means of curl program.

For example, thefollowing command will create an open (publicly available) project named test-api which will be owned by a group with identifier equal to 2:

curl --user <username>:<password> --data "project%5Bname%5D=test-api&project%5Bowner_id%5D=2&project%5Bowner_type%5D=Group&project%5Bvisibility%5D=open" -i https://abf.io/api/v1/projects.json

(here <username> and <password> stand for you login credentials in ABF).

The user should have necessary permissions to create a project in that group, otherwise you will get "Access denied" error.

The '--data' option of curl automatically create a POST request. However, some API requests require diferent HTTP request types. If necessary, you can specify request type explicitly by means of '-X' option. For example, the following command will add a project with identifier equal to 1 to repository with identifier equal to 3:

curl --user <username>:<password> -X PUT -d project_id=1 -i https://abf.io/api/v1/repositories/3/add_project.json