Skip to content

Commit

Permalink
Encode data to utf-8 before sending #66
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkastelec committed May 7, 2023
1 parent 369ab54 commit 8088b49
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions custom_components/wemportal/wemportalapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def make_api_call(
response = self.session.get(url, headers=headers)
else:
headers["Content-Type"] = "application/json"
data = {k: v.encode('utf-8') if isinstance(v, str) else v for k, v in data.items()}
_LOGGER.debug(f"Sending POST request to {url} with headers: {headers} and data: {data}")
response = self.session.post(
url, headers=headers, data=json.dumps(data)
Expand Down Expand Up @@ -338,6 +339,8 @@ def change_value(
):
"""POST request to API to change a specific value"""
_LOGGER.debug("Changing value for %s", parameter_id)
# Encode into UTF-8
parameter_id = parameter_id.encode('utf-8')
data = {
"DeviceID": device_id,
"Modules": [
Expand Down

0 comments on commit 8088b49

Please sign in to comment.