REST API - View a list of departments


GET  /departments

  • This method allows a list of departments to be obtained.
  • To obtain detailed information about a specified department: GET /departments/{department_id}. Open url.png See the method.

Notes

      Open url.png  See Service Manager REST API Conventions

  • If successful, an HTTP status code 200 is returned.
    • By default, if the optional parameter fields is not used, only an extract of the most useful fields selected by EasyVista is displayed for each record provided.
    • A URL link (HREF) to each resource is provided so that the complete list of fields for a record can be obtained.

List of parameters / fields

Mandatory parameters

None

Optional parameters

You can use the parameters detailed below in the HTTP request string.

Minimum version Parameter Type Description / Example
max_rows integer Maximum number of records to display.
  • Default value: 100
  • example /departments?max_rows=5
sort string Sort in ascending or descending order.
  • Syntax: field1[+asc|+desc],field2[+asc|+desc],fieldn[+asc|+desc]
  • example /departments?sort=start_date+desc
fields string SSelect fields to display.
  • example /departments?fields=department_en,department_label,start_date,end_date
search string Search/filter the specified fields.   Open url.png See Description of the options.
  • example /departments?search=parent_department_path:"IT"

A search on a Date field is also possible.

  • example /departments?search=end_date:this_month
Oxygen 2.1.2 - Build 2018.1.183.0 search

(logical OR operator)

string Search/filter to several values from a same field
  • Syntax: search=field:value1,field:value2
  • example
    • /departments?search=department_id:6,department_id:7 ==> all the departments in which the department_id field is equal to 6 or 7
Oxygène 1.7 - Build 2018.1.131.0 ~

(equivalent to like)

string Include the results which begin with or contain a given character string.
  • Syntax: ~ following by the string to include enclosed in quotation marks.
  • You should use the wildcard character *.
    • < string >* = include what begins with < string >.
    • *< string >* = include what contains < string >.
  • example
    • /departments?search=department_en~"Sal*" ==> all the departments in which the department_en field begins with Sal
    • /departments?search=department_en~"*Sal*" ==> all the departments in which the department_en field contains Sal
Oxygen 1.7 - Build 2018.1.131.0 !~

(equivalent to not like)

string Exclude the results which begin with or contain a given character string.
  • Syntax: !~ following by the string to exclude enclosed in quotation marks.
  • You should use the wildcard character *.
    • < string >* = exclude what begins with < string >.
    • *< string >* = exclude what contains < string >.
  • example
    • /departments?search=department_en!~"Sal*" ==> all the departments by excluding those in which the department_en field begins with Sal
    • /departments?search=department_en!~"*Sal*" ==> all the departments by excluding those in which the department_en field contains Sal
Oxygen 1.7 - Build 2018.1.131.0 !

(equivalent to not)

string Exclude all results equal to a given character string.
  • Syntax: ! following by the string to exclude enclosed in quotation marks.
  • example /departments?search=department_en!"Sales" ==> all the departments by excluding those in which the department_en field is equal to Sales
Oxygen 2.1.2 - Build 2018.1.183.0 is_null string Retrieve all results in which the field has no value (field value = null)
  • Syntax: Field name following by "is_null"
  • example
    • /departments?search=department_en:"is_null"&sort=department_id+asc ==> all the departments in which the department_en field has no value, sorted in ascending identifier
Oxygen 2.1.2 - Build 2018.1.183.0 is_not_null string Retrieve all results in which the field has a value (field value = not null)
  • Syntax: Field name following by "is_not_null"
  • example
    • /departments?search=department_en:"is_not_null"&sort=department_id+asc ==> all the departments in which the department_en field has a value, sorted in ascending identifier
Oxygen 1.7 - Build 2018.1.131.0 formatDate string Format display of Date fields in the HTTP request result.   Open url.png See Description of the options.
  • example
    • /departments?fields=last_update&formatDate=l/M/Y ==> "last_update_format": "Friday/Nov/2018"
    • /departments?fields=last_update&formatDate=l jS \of F Y h:i:s A ==> "last_update_format": "Friday 16th of November 2018 12:00:00 AM"

Optional fields

You can use all the fields from the AM_DEPARTMENT table in the body of the HTTP request except those mentioned below.

NotAuthorizedOptionalFields_Department
  • label_color ; label_font ; label_size 
  • property_color ; property_font ; property_size 
  • xpos ; ypos ; zpos 
  • lft ; rgt ; level
  • path_to_compute

HTTP status codes for the method

StatusHeader
Code Error Description
Status200
200 OK (Success) Request processed successfully.
Status401
401 Unauthorized Authentication process for accessing the resource is incorrect: Login/Password incorrect, Invalid session, Incorrect Service Manager account.

example

{
 "error": "Invalid Login / Password"
}

Example

Result for 3 departments (status code 200)

{
   "HREF": "http://{your_server}/api/v1/{your_account}/departments?max_rows=3",
   "record_count": "3",
   "total_record_count": "69",
   "records": [
        {
           "HREF": "http://{your_server}/api/v1/{your_account}/departments/5",
           "DEPARTMENT_CODE": "",
           "DEPARTMENT_EN": "-",
           "DEPARTMENT_PATH": "",
           "DEPARTMENT_ID": "5",
           "DEPARTMENT_LABEL": ""
        },
        {
           "HREF": "http://{your_server}/api/v1/{your_account}/departments/6",
           "DEPARTMENT_CODE": "",
           "DEPARTMENT_EN": "Sales",
           "DEPARTMENT_PATH": "Sales",
           "DEPARTMENT_ID": "6",
           "DEPARTMENT_LABEL": ""
        },
        {
           "HREF": "http://{your_server}/api/v1/{your_account}/departments/7",
           "DEPARTMENT_CODE": "",
           "DEPARTMENT_EN": "International USA",
           "DEPARTMENT_PATH": "Sales/Export",
           "DEPARTMENT_ID": "7",
           "DEPARTMENT_LABEL": ""
      }
    ]
}


ConventionsAPI

REST API Conventions

Convention Meaning
Orange Parameters used in an HTTP request string which do not correspond to Service Manager database fields.

example   Method View a list of assets


https://{your_server}/api/v1/{your_account}/assets?max_rows=3&fields=asset_tag

Black and Bold Parameters used in the URL of an HTTP request which correspond to Service Manager database fields.

example   Method View an asset


https://{your_server}/api/v1/{your_account}/assets/{asset_id}

Green Parameters used in the body of an HTTP request which represent JSON object names corresponding to Service Manager database fields; they allow the value of a database field to be assigned or modified.

example   Method Close an incident/request

{  "closed": {  "end_date": "11/20/2019 12:12:12",  }  }
Parameters used in the body of an HTTP request which represent JSON object names not corresponding to Service Manager database fields.

example   Method Reopen an incident/request

{  "restarted": {  "comment": "string (required)"  }  }

Tags:
Last modified by Unknown User on 2021/04/20 15:35
Created by Administrator XWiki on 2017/12/21 08:52

Shortcuts

Recent changes
•  EV Service Manager
•  Service Apps
•  EV Self Help
•  Service Bots

Powered by XWiki ©, EasyVista 2021