You should always provide a Content-Type header in your HTTP calls. Currently, the API supports:
GET requests must have an empty body. You must pass all parameters in URL. Failing to do so will trigger an HTTP 400 response.
By default, sessions used in this API are read-only. Only some methods have write access to session:
You could pass an additional parameter "session_write=true" to bypass this default. This read-only mode allow to use this API with parallel calls. In write mode, sessions are locked and your client must wait the end of a call before the next one can execute.
You can filter API access by enable the following parameters in GLPI General Configuration (API tab):
Session and App tokens could be provided in query string instead of header parameters.
Parameters: (Headers)
OR
Examples usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: Basic Z2xwaTpnbHBp" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/initSession'
< 200 OK
< {
"session_token": "83af7e620c83a50a18d3eac2f6ed05a3ca0bea62"
}
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: user_token q56hqkniwot8wntb3z1qarka5atf365taaa2uyjrn" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/initSession?get_full_session=true'
< 200 OK
< {
"session_token": "83af7e620c83a50a18d3eac2f6ed05a3ca0bea62",
"session": {
'glpi_plugins': ...,
'glpicookietest': ...,
'glpicsrftokens': ...,
...
}
}
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/killSession'
< 200 OK
This endpoint allows to request password recovery and password reset. This endpoint works under the following conditions: * GLPI has notifications enabled * the email address of the user belongs to a user account.
Reset password request:
$ curl -X PUT \
-H 'Content-Type: application/json' \
-d '{"email": "user@domain.com"}' \
'http://path/to/glpi/apirest.php/lostPassword'
< 200 OK
Password reset :
$ curl -X PUT \
-H 'Content-Type: application/json' \
-d '{"email": "user@domain.com", \
"password_forget_token": "b0a4cfe81448299ebed57442f4f21929c80ebee5" \
"password": "NewPassword" \
}' \
'http://path/to/glpi/apirest.php/lostPassword'
< 200 OK
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMyProfiles'
< 200 OK
< {
'myprofiles': [
{
'id': 1
'name': "Super-admin",
'entities': [
...
],
...
},
....
]
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getActiveProfile'
< 200 OK
< {
'name': "Super-admin",
'entities': [
...
]
}
Example usage (CURL):
$ curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"profiles_id": 4}' \
'http://path/to/glpi/apirest.php/changeActiveProfile'
< 200 OK
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getMyEntities'
< 200 OK
< {
'myentities': [
{
'id': 71
'name': "my_entity"
},
....
]
}
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getActiveEntities'
< 200 OK
< {
'active_entity': {
'id': 1,
'active_entity_recursive': true,
'active_entities': [
{"id":1},
{"id":71},...
]
}
}
Example usage (CURL):
$ curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"entities_id": 1, "is_recursive": true}' \
'http://path/to/glpi/apirest.php/changeActiveEntities'
< 200 OK
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getFullSession'
< 200 OK
< {
'session': {
'glpi_plugins': ...,
'glpicookietest': ...,
'glpicsrftokens': ...,
...
}
}
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/getGlpiConfig'
< 200 OK
< {
'cfg_glpi': {
'languages': ...,
'glpitables': ...,
'unicity_types':...,
...
}
}
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/Computer/71?expand_dropdowns=true'
< 200 OK
< {
"id": 71,
"entities_id": "Root Entity",
"name": "adelaunay-ThinkPad-Edge-E320",
"serial": "12345",
"otherserial": "test2",
"contact": "adelaunay",
"contact_num": null,
"users_id_tech": " ",
"groups_id_tech": " ",
"comment": "test222222qsdqsd",
"date_mod": "2015-09-25 09:33:41",
"autoupdatesystems_id": " ",
"locations_id": "00:0e:08:3b:7d:04",
"networks_id": " ",
"computermodels_id": "1298A8G",
"computertypes_id": "Notebook",
"is_template": 0,
"template_name": null,
"manufacturers_id": "LENOVO",
"is_deleted": 0,
"is_dynamic": 1,
"users_id": "adelaunay",
"groups_id": " ",
"states_id": "Production",
"ticket_tco": "0.0000",
"uuid": "",
"date_creation": null,
"links": [{
"rel": "Entity",
"href": "http://path/to/glpi/api/Entity/0"
}, {
"rel": "Location",
"href": "http://path/to/glpi/api/Location/3"
}, {
"rel": "Domain",
"href": "http://path/to/glpi/api/Domain/18"
}, {
"rel": "ComputerModel",
"href": "http://path/to/glpi/api/ComputerModel/11"
}, {
"rel": "ComputerType",
"href": "http://path/to/glpi/api/ComputerType/3"
}, {
"rel": "Manufacturer",
"href": "http://path/to/glpi/api/Manufacturer/260"
}, {
"rel": "User",
"href": "http://path/to/glpi/api/User/27"
}, {
"rel": "State",
"href": "http://path/to/glpi/api/State/1"
}]
}
Note: To download a document see Download a document file.
Returns:
and theses headers:
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/Computer/?expand_dropdowns=true'
< 206 OK
< Content-Range: 0-50/200
< Accept-Range: 990
< [
{
"id": 34,
"entities_id": "Root Entity",
"name": "glpi",
"serial": "VMware-42 01 f4 65 27 59 a9 fb-11 bc cd b8 64 68 1f 4b",
"otherserial": null,
"contact": "teclib",
"contact_num": null,
"users_id_tech": " ",
"groups_id_tech": " ",
"comment": "x86_64/00-09-15 08:03:28",
"date_mod": "2011-12-16 17:52:55",
"autoupdatesystems_id": "FusionInventory",
"locations_id": " ",
"networks_id": " ",
"computermodels_id": "VMware Virtual Platform",
"computertypes_id": "Other",
"is_template": 0,
"template_name": null,
"manufacturers_id": "VMware, Inc.",
"is_deleted": 0,
"is_dynamic": 1,
"users_id": " ",
"groups_id": " ",
"states_id": "Production",
"ticket_tco": "0.0000",
"uuid": "4201F465-2759-A9FB-11BC-CDB864681F4B",
"links": [{
"rel": "Entity",
"href": "http://path/to/glpi/api/Entity/0"
}, {
"rel": "AutoUpdateSystem",
"href": "http://path/to/glpi/api/AutoUpdateSystem/1"
}, {
"rel": "Domain",
"href": "http://path/to/glpi/api/Domain/12"
}, {
"rel": "ComputerModel",
"href": "http://path/to/glpi/api/ComputerModel/1"
}, {
"rel": "ComputerType",
"href": "http://path/to/glpi/api/ComputerType/2"
}, {
"rel": "Manufacturer",
"href": "http://path/to/glpi/api/Manufacturer/1"
}, {
"rel": "State",
"href": "http://path/to/glpi/api/State/1"
}]
},
{
"id": 35,
"entities_id": "Root Entity",
"name": "mavm1",
"serial": "VMware-42 20 d3 04 ac 49 ed c8-ea 15 50 49 e1 40 0f 6c",
"otherserial": null,
"contact": "teclib",
"contact_num": null,
"users_id_tech": " ",
"groups_id_tech": " ",
"comment": "x86_64/01-01-04 19:50:40",
"date_mod": "2012-05-24 06:43:35",
...
}
]
Returns:
and theses headers:
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/User/2/Log'
< 200 OK
< Content-Range: 0-50/200
< Accept-Range: 990
< [
{
"id": 22117,
"itemtype": "User",
"items_id": 2,
"itemtype_link": "Profile",
"linked_action": 17,
"user_name": "glpi (27)",
"date_mod": "2015-10-13 10:00:59",
"id_search_option": 0,
"old_value": "",
"new_value": "super-admin (4)"
}, {
"id": 22118,
"itemtype": "User",
"items_id": 2,
"itemtype_link": "",
"linked_action": 0,
"user_name": "glpi (2)",
"date_mod": "2015-10-13 10:01:22",
"id_search_option": 80,
"old_value": "Root entity (0)",
"new_value": "Root entity > my entity (1)"
}, {
...
}
]
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"items": [{"itemtype": "User", "items_id": 2}, {"itemtype": "Entity", "items_id": 0}]}' \
'http://path/to/glpi/apirest.php/getMultipleItems?items\[0\]\[itemtype\]\=User&items\[0\]\[items_id\]\=2&items\[1\]\[itemtype\]\=Entity&items\[1\]\[items_id\]\=0'
< 200 OK
< Content-Range: 0-50/200
< Accept-Range: 990
< [{
"id": 2,
"name": "glpi",
...
}, {
"id": 0,
"name": "Root Entity",
...
}]
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/listSearchOptions/Computer'
< 200 OK
< {
"common": "Characteristics",
1: {
'name': 'Name'
'table': 'glpi_computers'
'field': 'name'
'linkfield': 'name'
'datatype': 'itemlink'
'uid': 'Computer.name'
},
2: {
'name': 'ID'
'table': 'glpi_computers'
'field': 'id'
'linkfield': 'id'
'datatype': 'number'
'uid': 'Computer.id'
},
3: {
'name': 'Location'
'table': 'glpi_locations'
'field': 'completename'
'linkfield': 'locations_id'
'datatype': 'dropdown'
'uid': 'Computer.Location.completename'
},
...
}
Parameters: (query string)
criteria: array of criterion objects to filter search. Optional.
You can optionally precise meta=true
to pass a searchoption of another itemtype (meta-criteria).
Each criterion object must provide at least:
And you can pass a direct searchoption usage :
Or a list of sub-nodes with the key:
Ex:
...
"criteria":
[
{
"field": 1,
"searchtype": 'contains',
"value": ''
}, {
"link": 'AND',
"field": 31,
"searchtype": 'equals',
"value": 1
}, {
"link": 'AND',
"meta": true,
"itemtype": 'User',
"field": 1,
"searchtype": 'equals',
"value": 1
}, {
"link": 'AND',
"criteria" : [
{
"field": 34,
"searchtype": 'equals',
"value": 1
}, {
"link": 'OR',
"field": 35,
"searchtype": 'equals',
"value": 1
}
]
}
]
...
metacriteria (optional): array of meta-criterion objects to filter search. Optional.
A meta search is a link with another itemtype (ex: Computer with softwares).
Deprecated: Now criteria support meta flag, you should use it instead direct metacriteria option.
Each meta-criterion object must provide:
Ex:
...
"metacriteria":
[
{
"link": 'AND',
"itemtype": 'Monitor',
"field": 2,
"searchtype": 'contains',
"value": ''
}, {
"link": 'AND',
"itemtype": 'Monitor',
"field": 3,
"searchtype": 'contains',
"value": ''
}
]
...
sort (default 1): id of the searchoption to sort by. Optional.
giveItems (default false): a boolean to retrieve the data with the html parsed from core, new data are provided in data_html key.
¹ - contains will use a wildcard search per default. You can restrict at the beginning using the ^ character, and/or at the end using the $ character.
Returns:
200 (OK) with all rows data with this format:
{
"totalcount": ":numberofresults_without_pagination",
"range": ":start-:end",
"data": [
{
":searchoptions_id": "value",
...
},
{
...
}
],
"rawdata": {
...
}
}
206 (PARTIAL CONTENT) with rows data (pagination doesn't permit to display all rows).
401 (UNAUTHORIZED).
and theses headers:
Example usage (CURL):
curl -g -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/search/Monitor?\
criteria\[0\]\[link\]\=AND\
\&criteria\[0\]\[itemtype\]\=Monitor\
\&criteria\[0\]\[field\]\=23\
\&criteria\[0\]\[searchtype\]\=contains\
\&criteria\[0\]\[value\]\=GSM\
\&criteria\[1\]\[link\]\=AND\
\&criteria\[1\]\[itemtype\]\=Monitor\
\&criteria\[1\]\[field\]\=1\
\&criteria\[1\]\[searchtype\]\=contains\
\&criteria\[1\]\[value\]\=W2\
\&range\=0-2\&&forcedisplay\[0\]\=1'
< 200 OK
< Content-Range: 0-2/2
< Accept-Range: 990
< {"totalcount":2,"count":2,"data":{"11":{"1":"W2242","80":"Root Entity","23":"GSM"},"7":{"1":"W2252","80":"Root Entity","23":"GSM"}}}%
Parameters: (JSON Payload)
Important: In case of 'multipart/data' content_type (aka file upload), you should insert your parameters into a 'uploadManifest' parameter. Theses serialized data should be a JSON string.
Returns:
Examples usage (CURL):
$ curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"name": "My single computer", "serial": "12345"}}' \
'http://path/to/glpi/apirest.php/Computer/'
< 201 OK
< Location: http://path/to/glpi/api/Computer/15
< {"id": 15}
$ curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": [{"name": "My first computer", "serial": "12345"}, {"name": "My 2nd computer", "serial": "67890"}, {"name": "My 3rd computer", "serial": "qsd12sd"}]}' \
'http://path/to/glpi/apirest.php/Computer/'
< 207 OK
< Link: http://path/to/glpi/api/Computer/8,http://path/to/glpi/api/Computer/9
< [ {"id":8, "message": ""}, {"id":false, "message": "You don't have permission to perform this action."}, {"id":9, "message": ""} ]
Note: To upload a document see Upload a document file.
Example usage (CURL):
$ curl -X PUT \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"otherserial": "xcvbn"}}' \
'http://path/to/glpi/apirest.php/Computer/10'
< 200 OK
[{"10":true, "message": ""}]
$ curl -X PUT \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"id": 11, "otherserial": "abcde"}}' \
'http://path/to/glpi/apirest.php/Computer/'
< 200 OK
[{"11":true, "message": ""}]
$ curl -X PUT \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": [{"id": 16, "otherserial": "abcde"}, {"id": 17, "otherserial": "fghij"}]}' \
'http://path/to/glpi/apirest.php/Computer/'
< 207 OK
[{"8":true, "message": ""},{"2":false, "message": "Item not found"}]
Parameters: (query string)
id parameter has precedence over input payload.
Example usage (CURL):
$ curl -X DELETE \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/Computer/16?force_purge=true'
< 200 OK
[{"16":true, "message": ""}]
$ curl -X DELETE \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"id": 11}, "force_purge": true}' \
'http://path/to/glpi/apirest.php/Computer/'
< 200 OK
[{"11":true, "message": ""}]
$ curl -X DELETE \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": [{"id": 16}, {"id": 17}]}' \
'http://path/to/glpi/apirest.php/Computer/'
< 207 OK
[{"16":true, "message": ""},{"17":false, "message": "Item not found"}]
See Add item(s) and apply specific instructions below.
Uploading a file requires use of 'multipart/data' content_type. The input data must be send in a 'uploadManifest' parameter and use the JSON format.
Examples usage (CURL):
$ curl -X POST \
-H 'Content-Type: multipart/form-data' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-F 'uploadManifest={"input": {"name": "Uploaded document", "_filename" : ["file.txt"]}};type=application/json' \
-F 'filename[0]=@file.txt' \
'http://path/to/glpi/apirest.php/Document/'
< 201 OK
< Location: http://path/to/glpi/api/Document/1
< {"id": 1, "message": "Document move succeeded.", "upload_result": {...}}
Parameters: (query string)
id parameter has precedence over input payload.
Returns:
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-H "Accept: application/octet-stream" \
-d '{"input": {"id": 11}}' \
'http://path/to/glpi/apirest.php/Document/'
< 200 OK
The body of the answer contains the raw file attached to the document.
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
-d '{"input": {"id": 11}}' \
'http://path/to/glpi/apirest.php/Document/&alt=media'
< 200 OK
The body of the answer contains the raw file attached to the document.
Example usage (CURL):
$ curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-H "App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7" \
'http://path/to/glpi/apirest.php/User/2/Picture/'
< 200 OK
The body of the answer contains the raw image.
The desired resource (itemtype-id) was not found in the GLPI database.
The HTTP body must be an an array of objects.
You specified an inexistent or not not allowed resource.
The current logged user miss rights in his profile to do the provided action. Alter this profile or choose a new one for the user in GLPI main interface.
The Session-Token provided in header is invalid. You should redo an Init session request.
You miss to provide Session-Token in header of your HTTP request.
The current API requires an App-Token header for using its methods.
It seems the provided application token doesn't exists in GLPI API configuration.
You must mark the item for deletion before actually deleting it
We can't find an active client defined in configuration for your IP. Go to the GLPI Configuration > Setup menu and API tab to check IP access.
One of theses parameter(s) is missing:
The GLPI setup forbid the login with credentials, you must login with your user_token instead. See your personal preferences page or setup API access in GLPI main interface.
The provided user_token seems invalid. Check your personal preferences page in GLPI main interface.
We cannot login you into GLPI. This error is not relative to API but GLPI core. Check the user administration and the GLPI logs files (in files/_logs directory).
You asked a inexistent resource (endpoint). It's not a predefined (initSession, getFullSession, etc) nor a GLPI CommonDBTM resources.
See this documentation for predefined ones or List itemtypes for available resources
We suspect an SQL error. This error is not relative to API but to GLPI core. Check the GLPI logs files (in files/_logs directory).
The range parameter you provided is superior to the total count of available data.
We cannot add the object to GLPI. This error is not relative to API but to GLPI core. Check the GLPI logs files (in files/_logs directory).
Some of the object you wanted to add triggers an error. Maybe a missing field or rights. You'll find with this error a collection of results.
We cannot update the object to GLPI. This error is not relative to API but to GLPI core. Check the GLPI logs files (in files/_logs directory).
Some of the object you wanted to update triggers an error. Maybe a missing field or rights. You'll find with this error a collection of results.
We cannot delete the object to GLPI. This error is not relative to API but to GLPI core. Check the GLPI logs files (in files/_logs directory).
Some of the objects you want to delete triggers an error, maybe a missing field or rights. You'll find with this error, a collection of results.
By default, you can use http://path/to/glpi/apirest.php without any additional configuration.
You'll find below some examples to configure your web server to redirect your http://.../glpi/api/ URL to the apirest.php file.
We provide in root .htaccess of GLPI an example to enable API URL rewriting.
You need to uncomment (removing #) theses lines:
#<IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule api/(.*)$ apirest.php/$1
#</IfModule>
By enabling URL rewriting, you could use API with this URL : http://path/to/glpi/api/. You need also to enable rewrite module in apache httpd and permit GLPI's .htaccess to override server configuration (see AllowOverride directive).
Note for apache+fpm users:
You may have difficulties to pass Authorization header in this configuration. You have two options :
user_token
or credentials (login/password) in the http query (as GET parameters).SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
.This example of configuration was achieved on ubuntu with php7 fpm.
server {
listen 80 default_server;
listen [::]:80 default_server;
# change here to match your GLPI directory
root /var/www/html/glpi/;
index index.html index.htm index.nginx-debian.html index.php;
server_name localhost;
location / {
try_files $uri $uri/ =404;
autoindex on;
}
location /api {
rewrite ^/api/(.*)$ /apirest.php/$1 last;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# # see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
# allow directory index
fastcgi_index index.php;
}
}