The 500 status code generally represents a server problem. You could wait for some time then test again. If the issue doesn't fixed, please 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.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.