0

Say you have a content type Exercise which has a Related Users paragraph field. In turn, Related Users has a user reference field:

(content type) exercise --> (paragraph) related_users --> (user) user

I want to filter all Exercises with a certain related user:

/api/node/exercise?filter[field_related_users.field_user.name]=some_user

But it returns empty data: "data": [],. Same if tried with user id.

I'm sending a request with admin user, so there are no permission issues. Also, I did a similar filtering on a referenced content type (with a user reference) and it does return data.

I couldn't find anything related to this in JSON:API open issues. Does filtering by paragraph reference work differently? Or maybe there are limitations on this?

0

According to this issue, Unable to filter on columns of entity reference fields. It seems like you need to add .entity after the field name to the entity reference fields.

Try to use this URL instead:

/api/node/exercise?filter[field_related_users.entity.field_user.entity.name]=some_user

Or if field_related_users can contain multiple values, you might want to do like this instead:

/api/node/exercise?filter[field_related_users.0.entity.field_user.entity.name]=some_user
  • That's useful to know, thanks. I tried it, but still empty data is returned. What else do you think could be causing it? Have you ever tried? – Davit Magaldadze Nov 25 '19 at 17:46
  • I have tried something similar. Are you sure that the user that’s referenced has the name you filter on? – user72672 Nov 25 '19 at 18:47
  • Maybe try to filter on .id and check for the entity ID to see if it returns something. – user72672 Nov 25 '19 at 18:48

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.