JSON API – Departments
  • 14 Sep 2020
  • 1 Minute To Read
  • Contributors
  • Print
  • Share
  • Dark
    Light

JSON API – Departments

  • Print
  • Share
  • Dark
    Light

This page explains the API functions for the querying and updating of departments within your Nimblex system.

[toc heading_levels=”1,2″]

Departments

List Departments

Get a list of all departments in the system.

GET @apiroot/departments

Example Request

EMPTY

Example Response

{
    "data": [
		{
			"type": "department", /* user, guest or group */
			"id": "Accounts",
			"attributes": {
			    "departmentType": "Department",
			    "location": "1 Fake Street, Heidelberg"
			}
		},
		{
			"type": "department",
			"id": "Human Resources",
			"attributes": {
			    "departmentType": "Department",
			    "location": "2 Fake Street, Heidelberg"
			}
		}
	]
}

Read Department

GET @apiroot/departments/<urlencoded rolename>

Example Request

EMPTY

Example Response

{
    "data": {
        "type": "department", /* user, guest or group */
        "id": "Accounts",
        "links": {
            "self": "@apiroot/departments/Accounts"
        },
        "relationships": {
            "parent": {
                "links": {
                    "self": "@apiroot/roles/Accounts/relationships/parent",
                    "related": "@apiroot/departments/Operations"
                }
            }
        },
        "attributes": {
            "departmentType": "Department",
            "location": "1 Fake Street, Heidelberg"
        }
    }
}

Record, folder or file does not exist:
404 Not Found EMPTY

Create Department

POST @apiroot/departments

Example Request

{
    "data": {
        "type": "department",
        "id": "Human Resources",
        "attributes": {
            "departmentType": "Department",
            "location": "2 Fake Street, Heidelberg"
        }
    }
}

Example Response

{
    "data": {
        "type": "department",
        "id": "Human Resources",
        "attributes": {
            "departmentType": "Department",
            "location": "2 Fake Street, Heidelberg"
        }
    }
}

Update Department

PATCH @apiroot/departments/<urlencoded departmentname>

Example Request

{
    "data": {
        "type": "department",
        "id": "People and Culture",
        "attributes": {
            "departmentType": "Department",
            "location": "2 Fake Street, Heidelberg"
        }
    }
}

Example Response

Success:
200 Success EMPTY

No such role:
404 Not Found EMPTY

Delete Department

DELETE @apiroot/departments/<urlencoded departmentname>

Example Request

EMPTY

Example Response

Success:
200 Success EMPTY

No such role:
404 Not Found EMPTY

Department Parent

Get Department Parent

GET @apiroot/departments/<urlencoded departmentname> /relationships/parent

Example Request

EMPTY

Example Response

Child of a department:

{
    "data": {
        "type": "department",
        "id": "Operations",
        "attributes": {
            "departmentType": "Division",
            "location": "3 Fake Street, Heidelberg"
        }
    }
}

Not a child of a department:

{
    "data": null
}

Update/Remove Department Parent

PATCH @apiroot/departments/<urlencoded departmentname> /relationships/parent

Set Parent

Example Request

{
    "data": {
        "type": "department",
        "id": "Accounts"
    }
}

Example Response

Success:
200 Success EMPTY

No such user:
404 Not Found EMPTY

Clear Parent

Example Request

{
    "data": null
}

Example Response

Success:
200 Success EMPTY

No such user:
404 Not Found EMPTY

Was This Article Helpful?