Reputation: 2876
I have the following google cloud function:
def run_msg(event, context):
print(event["data"])
url = 'google_chat_hook'
bot_message = {
'text' : '{}'.format(event["data"])}
message_headers = { 'Content-Type': 'application/json; charset=UTF-8'}
http_obj = Http()
response = http_obj.request(
uri=url,
method='POST',
headers=message_headers,
body=dumps(bot_message),
)
When I'm testing the function directly from the Cloud Function Interface with the following trigger event {"data": {"message": "test"}}
I have the right message being published in google chat => {"message": "test"}
but when I'm publishing a message from pub sub manually I have the following kind of stuff being posted on google chat iB7Im1lc3NhZ2UiOiAibXNnX2Nvb2wifX
I can't understand what's happening here.
Upvotes: 0
Views: 866
Reputation: 75715
Simply copy paste the sample code in the documentation
base64.b64decode(event['data']).decode('utf-8')
Voilà! It's base64 encoded. Decode it and you will see it!
Upvotes: 3