Issue
-
Having a relationship between two objects A and B.
It is possible to make queries to the /o/c/as api filtering by a field of object B as nestedField.
curl -X 'GET' \
'http://www.localhost:8080/o/c/as/?filter=aB%2Ftext eq 'BBB' &nestedFields=aB' \
-H 'accept: application/json' \
-H 'x-csrf-token: 8LHnmePz'
but filtering from the child perspective in the hierarchy (/o/c/bs) seems not to be possible:
curl -X 'GET' \
'http:/www.localhost:8080/o/c/bs/?filter=r_aB_c_a%2Ftext eq 'AAA'&nestedFields=r_aB_c_a' \
-H 'accept: application/json' \
-H 'x-csrf-token: 8LHnmePz'
Error: response status is 400
{
"status": "BAD_REQUEST",
"title": "A property used in the filter criteria is not supported: r_aB_c_a/test eq 'AAA'",
"type": "InvalidFilterException"
}
Environment
- Liferay DXP 7.4+
Resolution
- In this case the issue is that the filter expression is not the correct one for the bs part. From the API perspective, the relationship name is the same from both sides of the relationship, so, to make queries from (/o/c/bs) you have to use the “same” expression as from /o/c/as:
http://www.localhost:8080/o/c/bs/?filter=aB%2Ftext eq 'AAA' &nestedFields=aB