Chris
Chris

Reputation: 14218

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?

Upvotes: 7

Views: 6170

Answers (1)

Domi
Domi

Reputation: 51

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).

Upvotes: 5

Related Questions