2

When i try to get data using the JSON API module, the field parent is always empty even if a term hierarchy exists.

For example, for a request to http://mysite.local/jsonapi/taxonomy_term/my_vocabulary/1a2a1fc1-b6d8-40be-a482-766ccab4aed1?_format=api_json&include=vid,parent, part of the response is the following one.

"parent":{  
        "data":[  

        ]
     },

How can I fix it?

1

See this core issue: https://www.drupal.org/node/2543726

This will address this. Right now, parent is a special pseudo-field that only supports saving parent relationships but not actually loading them. That's why serialization doesn't work.

You would have to write your own serializer that uses the getParents methods of the taxonomy_term storage to load the data

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.