Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: /getActiveEntities response #965

Closed
humboldtux opened this issue Sep 11, 2016 · 10 comments
Closed

API: /getActiveEntities response #965

humboldtux opened this issue Sep 11, 2016 · 10 comments
Milestone

Comments

@humboldtux
Copy link
Contributor

humboldtux commented Sep 11, 2016

I get this answer by requesting /getActiveEntities:

$ curl -H "Session-Token: 7r7436i0u4m0qqdn0v5rc43el5" 'http://glpi.lan:8080/apirest.php/getActiveEntities'

{"active_entity":1,"active_entity_recursive":true,"active_entities":{"1":1,"2":2}}

Where, from the official API documentation, the response should be:
{"active_entity":1,"active_entity_recursive":true,"active_entities":[{"1":1},{"2":2}]}

Even better, could the reponse of this endpoint be changed to:

{"active_entity":{"id":1,"active_entity_recursive":true,"active_entities":[{"id":1},{"id":2}]}}

It follows http://jsonapi.org/, and is easier to parse.

I'm using Master.
Server configuration:

Informations

sur le système, l'installation et la configuration
[code]

GLPI 9.1-RC2-114-g975ad0f ( => /var/www/html/glpi.git)

Server

Operating system: Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) x86_64
PHP 5.6.24-0+deb8u1 apache2handler (Core, PDO, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apache2handler, bcmath, bz2,
calendar, ctype, curl, date, dba, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, json, libxml, mbstring,
mhash, mysql, mysqli, openssl, pcre, pdo_mysql, posix, readline, session, shmop, soap, sockets, standard, sysvmsg, sysvsem,
sysvshm, tokenizer, wddx, xml, xmlreader, xmlwriter, zip, zlib)
Setup: max_execution_time="30" memory_limit="128M" post_max_size="8M" safe_mode="" session.save_handler="files"
upload_max_filesize="2M"
Software: Apache/2.4.10 (Debian) (Apache/2.4.10 (Debian) Server at glpi.lan Port 8080)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
Server Software: (Debian)
Server Version: 5.5.50-0+deb8u1
Server SQL Mode:
Parameters: root@localhost/glpi
Host info: Localhost via UNIX socket

OK/var/www/html/glpi.git/config : OK
OK/var/www/html/glpi.git/files : OK
OK/var/www/html/glpi.git/files/_dumps : OK
OK/var/www/html/glpi.git/files/_sessions : OK
OK/var/www/html/glpi.git/files/_cron : OK
OK/var/www/html/glpi.git/files/_graphs : OK
OK/var/www/html/glpi.git/files/_lock : OK
OK/var/www/html/glpi.git/files/_plugins : OK
OK/var/www/html/glpi.git/files/_tmp : OK
OK/var/www/html/glpi.git/files/_rss : OK
OK/var/www/html/glpi.git/files/_uploads : OK
OK/var/www/html/glpi.git/files/_pictures : OK
OK/var/www/html/glpi.git/files/_log : OK
Web access to files directory is protectedWeb access to files directory is protected : OK

Libraries

htmLawed version 1.1.21 in (/var/www/html/glpi.git/lib/htmlawed)
phpCas version 1.3.4 in (/var/www/html/glpi.git/vendor/jasig/phpcas/source)
PHPMailer version 5.2.16 in (/var/www/html/glpi.git/vendor/phpmailer/phpmailer)
ZetaComponent ezcGraph installed in (/var/www/html/glpi.git/vendor/zetacomponents/graph/src): OK
Zend Framework in (/var/www/html/glpi.git/vendor/zendframework/zend-loader/src)
SimplePie version 1.4.1 in (/var/www/html/glpi.git/vendor/simplepie/simplepie/library)
TCPDF version 6.2.12 in (/var/www/html/glpi.git/vendor/tecnickcom/tcpdf)
ircmaxell/password-compat in (/var/www/html/glpi.git/vendor/ircmaxell/password-compat/lib). Compatitility: Ok
iacaml/autolink in (/var/www/html/glpi.git/vendor/iamcal/lib_autolink)
sabre/vobject in (/var/www/html/glpi.git/vendor/sabre/vobject/lib)
guzzlehttp/guzzle in ()`

@trasher
Copy link
Contributor

trasher commented Sep 13, 2016

I agree with changing the response, that sounds more logical to me.

@trasher
Copy link
Contributor

trasher commented Sep 15, 2016

@humboldtux changes have been made to the master branch; could you please test it and close this ticket if it is ok for you? Many thanks!

@trasher trasher added this to the 9.1 milestone Sep 15, 2016
@trasher
Copy link
Contributor

trasher commented Sep 15, 2016

This is on the orthagh:9.1/apijson.org_compat branch, not on the master; sorry for the confusion.

@humboldtux humboldtux changed the title API: /getMyEntities response API: /getActiveEntities response Sep 15, 2016
@humboldtux
Copy link
Contributor Author

humboldtux commented Sep 15, 2016

I get:

{
    "active_entity": {
        "id": 1,
        "active_entity_recursive": true,
        "active_entities": [1, 2]
    }
}

Where

{
    "active_entity": {
        "id": 1,
        "active_entity_recursive": true,
        "active_entities": [{
            "id": 1
        }, {
            "id": 2
        }]
    }
}

would be easier to parse.

@orthagh
Copy link
Contributor

orthagh commented Sep 15, 2016

still on my fork, you should have an array instead of an object on key active_entities

@trasher
Copy link
Contributor

trasher commented Sep 15, 2016

Fixed in the master, the real one! :)

@humboldtux
Copy link
Contributor Author

@orthagh, whether from updated master or your fork, i'm still getting

{
    "active_entity": {
        "id": 1,
        "active_entity_recursive": true,
        "active_entities": [1, 2]
    }
}

Is it the definitive response you want to return? not:

{
    "active_entity": {
        "id": 1,
        "active_entity_recursive": true,
        "active_entities": [{
            "id": 1
        }, {
            "id": 2
        }]
    }
}

@orthagh
Copy link
Contributor

orthagh commented Sep 16, 2016

It shouldn't : 406f0fe#diff-e01cdca9469fc2d2fa8a60ea83250903R303

It's now on this repo master

@trasher
Copy link
Contributor

trasher commented Sep 16, 2016

Using latest master, I still have the incorrect output:

{
  "active_entity": {
    "id": 0,
    "active_entity_recursive": 1,
    "active_entities": [
      0,
      1,
      2,
      3
    ]
  }
}

@trasher trasher reopened this Sep 16, 2016
@orthagh
Copy link
Contributor

orthagh commented Sep 16, 2016

oh ok, i missed you want this kind of output

trasher added a commit to trasher/glpi that referenced this issue Sep 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants