Welcome. Most common questions have answers on the forum - you can search using the magnifying glass icon.
There are answers on Power Query but not specifically on an error 500 issue - however there are a couple of posts on that in the context of trying to retrieve documents from the Filing history.
As usual I recommend working through each request manually using something like e.g. curl, so you can see exactly what is being sent and returned. In one of the threads above I posted a link to all the steps involved (and possible pitfalls) of requesting and downloading documents - this one:
Hopefully working through step by step will fix your issue. If not, you should have a particular step that is causing issues and some information around exactly what you’re sending. You could then post that here and see if anyone can help. (The only thing you should NOT post is your own API key in full).
I believe there are several places where you could trigger an error 500 (or other errors).
Good luck.