You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2021-10-01 10:40:44

Cyri1
Member
Registered: 2021-04-30
Posts: 2

Problem API Rest endpoint getMultipleItems

Hello,
I have a problem with api rest endpoint /apirest.php/getMultipleItems :
this is my code where $items = Array([items] => Array ([0] => Array ([itemtype] => Computer [items_id] => 15460 )[1] => Array([itemtype] => Monitor [items_id] => 2773))):

    $endpoint = 'https://xxxxxxxxxx/apirest.php/getMultipleItems?with_infocoms=true&expand_dropdowns=true&';
    $url = $endpoint . http_build_query($items);

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $credentials);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $response = curl_exec($curl);
    $response = json_decode($response, true);

    echo '<pre>';
    print_r($response);
    echo '</pre>';

Response :

    [1] => Array
        (
.........
            [monitortypes_id] => ECR-LCD
            [monitormodels_id] => 2450  <---------- API response is "2450" but in GLPI, the model is NOT "2450" but "245E1"
            [manufacturers_id] => Philips
.....)

Now i add a new monitor model and name it "245E2" via (+) button next to model in GLPI UI and, for the same monitor, i change model type to "245E2"

Response :
    [1] => Array
        (
.........
            [monitortypes_id] => ECR-LCD
            [monitormodels_id] => 24500  <---------- API response is "24500" and NOT 245E2
            [manufacturers_id] => Philips
.....)

Now i edit my monitor model ("245E2") and rename it "test" via (i) button next to model in GLPI UI

Response :
    [1] => Array
        (
.........
            [monitortypes_id] => ECR-LCD
            [monitormodels_id] => test <---------- API response is "test" > no problem
            [manufacturers_id] => Philips
.....)

GLPI Version : 9.4.2

It's a bug or am i doing something wrong ?

Thanks for help

Offline

#2 2021-10-01 11:11:53

Cyri1
Member
Registered: 2021-04-30
Posts: 2

Re: Problem API Rest endpoint getMultipleItems

After few test :
i think GLPI does some maths when model name is Number + E + Number

Last edited by Cyri1 (2021-10-01 13:08:00)

Offline

Board footer

Powered by FluxBB