Closed humboldtux closed 8 years ago
Also agree with proposed output, sounds more clear than it is actually.
Seems ok for me. @newls and @gatemed should take note of this change
@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 nothing new in master regarding this issue. Am i missing something? Should i test against orthagh/glpi?
@humboldtux sorry... this is noit yet in the master, I wanted your feedback before... You can use the orthagh:9.1/apijson.org_compat branch; thank you :)
I get:
{
"myprofiles": [{
"id": 1,
"name": "Self-Service",
"entities": {
"1": {
"id": 1,
"name": "Sub1",
"is_recursive": 1
},
"2": {
"id": 2,
"name": "Sub2",
"is_recursive": 1
}
}
}, {
"id": 4,
"name": "Super-Admin",
"entities": [{
"id": 0,
"name": "Root entity",
"is_recursive": 1
}]
}]
}
Where it would be better to have:
{
"myprofiles": [{
"id": 1,
"name": "Self-Service",
"entities": [{
"id": 1,
"name": "Sub1",
"is_recursive": 1
}, {
"id": 2,
"name": "Sub2",
"is_recursive": 1
}]
}, {
"id": 4,
"name": "Super-Admin",
"entities": [{
"id": 0,
"name": "Root entity",
"is_recursive": 1
}]
}]
}
Hello @humboldtux
Could you explain in detail the diff (and format/indent :) ) ?
On my side, i get the following data (the entities key matches an array and not an object) :
{
"myprofiles":[
{
"id":1,
"name":"Client - Simple",
"entities":[
{
"id":0,
"name":"Entité racine",
"is_recursive":1
}
]
},
{
"id":45,
"name":"only create ticket",
"entities":[
{
"id":0,
"name":"Entité racine",
"is_recursive":1
}
]
},
{
"id":4,
"name":"super-admin",
"entities":[
{
"id":0,
"name":"Entité racine",
"is_recursive":1
},
{
"id":1,
"name":"1 - Interne Teclib",
"is_recursive":1
}
]
},
{
"id":14,
"name":"TECLIB' Experts",
"entities":[
{
"id":0,
"name":"Entité racine",
"is_recursive":1
}
]
},
{
"id":13,
"name":"TECLIB' Helpdesk",
"entities":[
{
"id":0,
"name":"Entité racine",
"is_recursive":1
}
]
}
]
}
Hi @orthagh Sorry for the indentation, i fixed my previous comment. If you look closely at the output, you will see that the entities array of the first profile is wrong.
ok i got it, in my case, i have keys 0 & 1, so json_encode consider it as an array, in your cases, id are 1 and 2, and it results in a object transformation. I'll push a fix for that
Here is, could you update from my fork ?
Working like charm, thank you @orthagh
I reopen, we still need to merge the pull request :)
^^
Fixed in master (the real master, this time ;))
I get this answer by requesting /getMyProfiles:
$ curl -H "Session-Token: 7r7436i0u4m0qqdn0v5rc43el5" 'http://glpi.lan:8080/apirest.php/getMyProfiles'
{"1":{"name":"Self-Service","entities":[{"id":0,"name":"Root entity","is_recursive":1},{"id":1,"name":"Sub1","is_recursive":0}]},"6":{"name":"Technician","entities":[{"id":0,"name":"Root entity","is_recursive":1}]}}
Where, from the official API documentation, the response should be:
[ 1: { 'name': "Self-Service", 'entities': { ... }, ... }, .... ]
Even better, could the reponse of this endpoint be changed to:
{ "profiles": [ { "id":1,"name":"Self-Service","entities": [{"id":0,"name":"Root entity","is_recursive":1},{"id":1,"name":"Sub1","is_recursive":0}] }, { "id":6,"name":"Technician","entities": [{"id":0,"name":"Root entity","is_recursive":1}] } ] }
It follows http://jsonapi.org/, and is easier to parse.
I'm using Master. Server configuration: