The 500 status code generally represents a server problem. What we can do is to check whether there is a problem with the step of calling the API. Try to call the API in the graph explorer with a user with the permission of this site to check whether the issue still exists. And this API works well when I test in graph explorer.
If the issue still exists, I suggest you submit a ticket in the admin center with the request-id, then you could get the detailed error information.
Updated:
You need to use this api to get the site id:
GET /sites/{hostname}:/{server-relative-path}
Document:Get a site resource
Test demo for your reference:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.