Filter custom post type by category in REST API v2 in WordPress

admin

Administrator
Staff member
I am creating an Android app using the WP API. I managed to show a custom post type in the REST API which can be viewed in:

Code:
http://localhost/wordpress/wp-json/wp/v2/property

Now I want to filter properties by their category, e.g.
Code:
villa
,
Code:
home
,
Code:
rent
, etc. I have tried the following, but it does not work:

Code:
http://localhost/wordpress/wp-json/wp/v2/property?filter[category_name]=villa` 
http://localhost/wordpress/wp-json/wp/v2/property?filter[category]=apartment`