Skip to content

'latin-1' codec can't encode character #19

@GeirFrimann

Description

@GeirFrimann

I've created a REST API call from Thingsboard with the following included header:
Content-Type: application/json;charset=iso-8859-1 (tried with utf-8 as well)

Whenever any of the params for the sos-access contains swedish characters öäå, the lamda function raises this exception
(in this case for the letter å):
{
"errorMessage": "'latin-1' codec can't encode character '\\uffe5' in position 510: ordinal not in range(256)",
"errorType": "UnicodeEncodeError",
"stackTrace": [" File "/var/task/lambda_function.py", line 115, in lambda_handler\n AlarmResponse = client.send_alarm(\n", " File "/var/task/sos_access/client.py", line 176, in send_alarm\n return self._send_alarm(alarm_request)\n", " File "/var/task/sos_access/decorators.py", line 35, in retried_func\n result = func(*args, **kwargs)\n", " File "/var/task/sos_access/client.py", line 251, in _send_alarm\n alarm_response = self.transmit(\n", " File "/var/task/sos_access/client.py", line 367, in transmit\n transport.send(data.encode(self.ENCODING))\n"]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions