Make sure you are not trying to impersonate an app user. You can’t even impersonate your own app user. In case your app is triggered by an app user, make the call as app instead.
Possibly related: there is a bug in ACE’s generation of qsh that causes requests to fail from the back end when legacy userAccountIds are used directly within the URL path. This happens because ACE has a different understanding of which characters (such as “:”) are expected to be URI-encoded. This does not seem to be the case for your code though.
I see that you’re using ACT_AS_USER to call /wiki/rest/api/user/current. You might try ACT_AS_USER with /wiki/rest/api/user?userAccountId=<account> instead, as well as the latter call but without ACT_AS_USER, to see if you can if you get any different results that narrow down the source of failure.
Thank you for the answer. I will check how it works. As I understand it, this endpoint can be used without user impersonation, so my problem should be solved. However, it’s still strange that the endpoint we used before doesn’t work.