API Introduction
Introduction
Starting from version 0.2.0, the system provides an Open API interface, mainly used for automated testing, converting test results into defects, and continuously tracking and managing them.
How To Call
Third party software can access the system through the HTTP interface, and the system provides a key for different access parties. Each call requires adding this key to the header, as shown below:
var myHeaders = new Headers();
myHeaders.append("CAT2BUG-API-KEY", "202402110748485l2ug97j471ul9wq");
myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
myHeaders.append("Accept", "*/*");
myHeaders.append("Host", "127.0.0.1:2020");
myHeaders.append("Connection", "keep-alive");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("http://127.0.0.1:2020/api/defect", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The second line in the interface code above is the API key we mentioned. When calling the interface, it must be named CAT2BUG-API-KEY, and its value is obtained through the system application.
Prompt
Each API KEY is only valid for one project
Create Key
In [Project Option](../system/project.md#Project Option), select API KEY to enter the key settings interface. The key can be set to expire, and when it expires, the key will no longer be usable.