TestLink REST API Guide
TestLink REST API Guide
In this TestLink REST API guide, we will learn how to execute TestLink Rest API requests and some sample API endpoints. REST stands for Representational State Transfer. It allows interaction with systems built on the HTTP standard protocol and is an alternative to legacy systems built on SOAP(Simple Object Access Protocol).
Pre-requisites
- TestLink Web instance up and running
To execute API calls, we need to have the Testlink Web application up and running without any issues. Log in as the API user into the TestLink web application.
CRUD Operations
CRUD stands for Create, Read, Update, and Delete. These are the major operations that API calls perform on the server-side resources.
The analogous REST verbs for these operations are as follows:
- Create -> POST method.
- Read -> GET method.
- Update -> PUT method.
- Delete -> DELETE method.
Manual API Test Tool
We use Postman for testing and executing the REST API calls. A quick overview and download steps can be found at:
https://www.testingdocs.com/postman-api-tool/
TestLink REST API Versions
Testlink versions:
The current version of TestLink is 1.9.x. The upcoming version of the TestLink is 2.x
API versions are different from the Testlink web versions. There are multiple versions for the API endpoints, like.
- v1
- v2
- v3
We need to specify the version in the REST endpoint URL to hit the particular version.
http://<server_testlink_home>/lib/api/rest/v1/who
http://<server_testlink_home>/lib/api/rest/v2/who
Anatomy of API Request
Below is a API request executed to get the project’s information. Let’s understand the API request shown.
1- API endpoint. The server listens to the API request on this endpoint. Testlink might have many exposed endpoints each for a specific purpose.
2- HTTP method for the request. The shown call is a GET call.
3- Authorization – We need to specify the APIKEY
4- Request Headers for the API request. Content Type, Accept etc.
5 – Response code – 200 OK means Success.
6 – Response Body received from the TestLink server.
Advantages
Rest API allows us to interact with TestLink interaction in an automated fashion.
API opens doors to integration with other components like Mantis BTS, Jira, etc.
Debugging API errors
- https://www.testingdocs.com/questions/how-to-fix-slim-application-error-in-testlink/
- https://www.testingdocs.com/questions/how-to-fix-400-bad-request-error-in-testlink-api/
Sample API calls
http://localhost/testlink/lib/api/rest/v2/who
This API is just to check the Rest API status. If you get a 200 OK response status the Rest API setup is fine on the TestLink instance. Any other response code would need attention and debug.
http://localhost/testlink/lib/api/rest/v2/whoAmI
This API is just to check the Rest API status. If you get a 200 OK response status the Rest API setup is fine on the TestLink instance. Any other response code would need attention and debug.
http://localhost/testlink/lib/api/rest/v2/testprojects
This API call is used to Gell all the test projects created on the TestLink instance.
Sample REST API Response:
{
"status": "ok",
"message": "ok",
"item": [
{
"id": "1",
"notes": "<p>www.TestingDocs.com</p>",
"color": "",
"active": "1",
"option_reqs": "0",
"option_priority": "0",
"option_automation": "0",
"options": "O:8:"stdClass":4:{s:19:"requirementsEnabled";i:1;s:19:
"testPriorityEnabled";i:1;s:17:"automationEnabled";i:1;s:16:
"inventoryEnabled";i:0;}",
"prefix": "TDocs",
"tc_counter": "0",
"is_public": "1",
"issue_tracker_enabled": "0",
"code_tracker_enabled": "0",
"reqmgr_integration_enabled": "0",
"api_key": "7eb55806c7f7e8ccc83ce4b5b807c9866e5baba05430306f2525296d55db752b",
"name": "TestingDocsProject",
"effective_role": "8",
"itname": null,
"ittype": null,
"rmsname": null,
"rmstype": null,
"opt": {
"requirementsEnabled": 1,
"testPriorityEnabled": 1,
"automationEnabled": 1,
"inventoryEnabled": 0
}
}
]
}