$authors = get_users( array( 'role__in' => array( 'author' ) ) );
For more info see this page.
Thank you Michael for your help
I wanna the URL for this call
like: https://grandlb.com/wp-json/wp/v2/users/
I guess you want to get via REST API only the users that have a certain role? Take a look at the manual here: https://developer.wordpress.org/rest-api/reference/users/ – according to this it should work like this:
https://grandlb.com/wp-json/wp/v2/users?roles=author
But: this only works if you authenticate yourself for the request.
@threadi right
but if you open link you see “data”:{“status”:401}}, so not working
Hence also my hint:
But: this only works if you authenticate yourself for the request.
This is data that is not publicly accessible. If you access the API with a tool, you have to authenticate yourself at the same time. Here is an article about it: https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/