def _parse_api_response(self, method_name_int, kwargs, body):
        # FIXME: The ccu is performing wrong encoding at least for output of
        # executed rega scripts. But maybe this is a generic problem. Let's see
        # and only fix the known issues for the moment.
        if method_name_int in [ "rega_run_script", "interface_get_paramset_description",
                                "room_get_all" ]:
            body = AbstractAPI._replace_wrong_encoded_json(body)

        try:
            msg = json.loads(body)
        except Exception as e:
            raise PMException("Failed to parse response to %s (%s):\n%s\n" %
                                                    (method_name_int, e, body))

        if msg["error"] is not None:
            if msg["error"]["code"] == 501 and not self._call('rega_is_present'):
                raise PMConnectionError("The logic layer (ReGa) is not available (yet). When "
                                  "the CCU has just been started, please wait some time "
                                  "and retry.")
            else:
                raise PMException("[%s] %s: %s (Code: %s, Request: %r)" % (method_name_int,
                                                        msg["error"]["name"],
                                                        msg["error"]["message"],
                                                        msg["error"]["code"],
                                                        kwargs))

        return msg["result"]