Returns the departments to which a user belongs.
Test hosts are registered in departments in QAComplete. If your authenticating user belongs only to one department, the API "knows" which department to use. However, if this user belongs to several departments, you need to specify a department in API calls explicitly.
You can use the /depts (GET)
operation to learn to which departments a user belongs to and to get the department information.
Authentication
Basic authentication using the login and password of the user whose departments you want to get. See Authentication for details.
Security Rights
The authenticating user needs no specific access rights.
Request Format
To get a user’s departments, send a GET request to the following URL:
Use the Authentication
request header based on the login e-mail address and password of this user.
A sample request:
GET http://yourserver.com/rest-api/service/automation/v2/depts HTTP/1.1
Host: yourserver.com
Connection: keep-alive
Accept: application/json
Authorization: Basic am9obkBleGFtcGxlLmNvbTpwQHNzd29yZA==
A sample cURL request to get departments for [email protected]:
curl -u [email protected]:p@ssword -H "Accept: application/json" http://yourserver.com/rest-api/service/automation/v2/depts
Response Format
On success, the operation responds with HTTP status code 200 and returns a JSON object with a list of the user’s departments. If the operation fails, it returns the appropriate status code and (optionally) the error description in the response body.
To count the departments, use the metadata.result_set.count
value.
-
If it is 1, other API operations do not need the department ID.
-
If it is 2 or more, extract the department IDs from the response for further use.
A sample response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 347
{
"metadata": {
"result_set": {
"count": 2,
"offset": 0,
"limit": 25,
"total": 2
},
"permissions": {
"acl": 0
}
},
"results": [
{
"id": 8162,
"name": "department name 1",
"company": "company name 1",
"date_created": "2009-09-21T14:09:15.4200000"
},
{
"id": 8165,
"name": "department name 2",
"company": "company name 2",
"date_created": "2010-03-02T12:59:31.1230000"
}
]
}
Metadata about the departments.
The number of the departments the user belongs to. The same as total
.
Reserved.
Reserved.
The number of the departments the user belongs to. The same as count
.
Reserved.
An array of the departments the user belongs to.
The department ID. If the user belongs to several departments, you need this ID to register test hosts and to get hosts by name.
The department name.
The company name.
The date and time the department was created in QAComplete.