Sign in
You won't have to setup another user to use the API. Every existing mite.user can activate the API in his user settings.
Please click on your user name in the upper right-hand corner of the mite.interface. Check the corresponding checkbox there, and you'll get your personal API key right away.
There are two ways to sign in: You can either use your regular user credentials that you specify when logging in with your browser. Or you can use your personal API key.
Enter your regular user credentials (username/e-mail and password) per HTTP basic. A pretty simple example using curl:
curl -u you@mail.com:yourpassword \
http://demo.mite.yo.lk/projects.xml
NOTE: Please replace the subdomain 'demo' with the accurate subdomain of your account throughout the following examples.
To authenticate using your API key, you can either send it as HTTP header 'X-MiteApiKey' or as paramter 'api_key':
curl -H 'X-MiteApiKey: apikey' \
http://demo.mite.yo.lk/projects.xml
curl http://demo.mite.yo.lk/projects.xml?api_key=apikey
Safety
HTTP basic authentication is used for authentication. You will have to transfer your authentication data with every request. HTTPS is therefore supported throughout the whole mite.api.
Reading data
By using the HTTP method GET, data can be read either in list form or as a single resource.
To read a single resource, the URL has to be composed of the path of the resource and the ID of the resource:
curl -v -H 'X-MiteApiKey: apikey' \
http://demo.mite.yo.lk/services/1.xml
A list can be read by using the path of the resource:
curl -v -H 'X-MiteApiKey: apikey' \
http://demo.mite.yo.lk/services.xml
If your request was interpreted successfully, you will receive a 200 OK as well as the requested data in XML format.
Writing data
By using the HTTP methods POST, PUT and DELETE, data can be written. XML format will be used. You should therefore send the string 'Content-type: application/xml' within the header of each request. Put the real data in the body – carefully wrapped in XML tags. Example:
curl -v -X POST \
-H 'X-MiteApiKey: apikey' \
-H 'Content-Type: application/xml' \
-d '<service><name>Coding</name></service>' \
http://demo.mite.yo.lk/services.xml
This request will create a new resource by using POST – in this example a new service named 'Coding'. If your request was interpreted successfully, you will receive a 201 Created as well as the complete object in the response body.
An object that was already created can be edited by using the PUT method:
curl -v -X PUT \
-H 'X-MiteApiKey: apikey' \
-H 'Content-Type: application/xml' \
-d '<service><name>Quality assurance</name></service>' \
http://demo.mite.yo.lk/services/1.xml
If the edit was successful, you will receive a 200 OK.
You can delete an object in a similar way by using the DELETE method. You won't have to add parameters in the request body of course:
curl -v -X DELETE -H 'X-MiteApiKey: apikey' \
http://demo.mite.yo.lk/services/1.xml
If the object was deleted successfully, you will receive a 200 OK as well.
Errors
If an error occurred, the mite.api will tell you by returning a 4xx or 5xx status code. In most cases you will be able to interpret the cause of error right away. In many cases the mite.api will return a short error message in plain text within the body of the request as well:
Response : 404 Not Found
<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Record not found.</error>
</errors>
Response : 422 Unprocessable Entity
<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Please name your project.</error>
</errors>
