GET/depts

Applies to QAComplete 14.3, last modified on February 19, 2024

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:

http://{server}/rest-api/service/automation/v2/depts

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"
    }
  ]
}

See Also

QAComplete Test Automation REST API Reference

Highlight search results