Hi all.
I found something strange when using REST API to get account information (i.e.: /Api/V8/module/Accounts?filter[id][eq]=<my_id_account>).
When I get information about a simple account without parent assigned, the response JSON have structure like this:
{
"data": [
{
"type": "Account",
"id": "my_account_id",
"attributes": {
"name": "ACCOUNT NAME",
"date_entered": "",
"date_modified": "2020-07-27T13:58:00+03:00",
"modified_user_id": "1",
[... omitted ...]
"parent_id": "",
"sic_code": "",
"parent_name": "",
"members": "",
"member_of": {},
[... omitted ... ]
}
}
]
}
Take a look at the field “member_of”. It is a JSON Object.
When the account, otherwise, have a parent, the structure changes (apparently a bit, but not so for a high level JSON library):
{
"data": [
{
"type": "Account",
"id": "other_account_id",
"attributes": {
"name": "OTHER ACCOUNT NAME",
"date_entered": "",
"date_modified": "2020-07-27T13:58:00+03:00",
"modified_user_id": "1",
[... omitted ...]
"parent_id": "parent_account_id",
"sic_code": "",
"parent_name": "PARENT ACCOUNT NAME",
"members": "",
"member_of": "",
[... omitted ... ]
}
}
]
}
Now, field “member_of” becomes a plain (empty) string… It is unparseable by high level JSON parsing library if it expects to receive an Object.
There seems to be an incoerent structure for the same entity type (an Account).
Any idea about it?