Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws lambda UTF-8 response header

I have a lambda function that returns a string that contains UTF-8 characters (german umlaute). However, The AWS API-Gateway response does not contain the utf-8 header. How can I add it so the client receives a readable response?

like image 785
Chris Avatar asked Nov 09 '22 18:11

Chris


1 Answers

I was able to solve this problem like this in Python:

return {
        'statusCode': 200,
        'headers': {
                "content-type":"application/json; charset=utf-8"},
        'body': json.dumps(data)
        }

I just needed to set the additional header "content-type". But I'm not sure whether you need to have "HTTP-Proxy-Integration" enabled (like i did).

like image 137
Domi Avatar answered Nov 14 '22 21:11

Domi