An API that connects multiple Microsoft services, enabling data access and automation across platforms
There are two things you need. First, to grant the permission entry on the site in question, by running a request similar to the one you've shown above. The requirement for this to work is to have the Sites.FullControl.All permission though, so make sure you've granted that, and if you are using delegate permissions, make sure the user running this query is listed as Site collection admin.
Next, you need the "restricted" app itself. The Sites.Selected permission is what you assign to the "restricted" app. Do not assign Sites.ReadWrite.All or any similar permissions to it, as the restricted access will not apply in such scenarios.
If you need more details on how Sites.Selected works, I have a guide here: https://michev.info/blog/post/3256/limiting-access-to-sharepoint-online-resources-via-the-graph-api