I solved my problem as follows, but it’s probably not the perfect solution.
Instead of using get_site_name(), I used get_site_base_path(), which doesn’t need any parameters. The result was for example like the following
./erp.mysite.local
Of course, it’s not getting the site_name, but for my needs it was perfect. Maybe someone can tell us how to get erp.mysite.local instead, without having to slice the string.
I got to the point, that I need the full url with a prefix.
If the site is ssl secured, it has to be https, if it’s not, it has to be http. If API requests go to http, the reply on a https site is moved permanently, which will lead to the fact, that the api call will not be successful.