When I tried LINE Beacon with M5 STICKC the other day, When I tried to use GAS which I have never used the webhook destination, I'm not sure where I'm addicted to.
It may be better to fix the Webhook destination every time because it is caused by trying out unknown functions together.
So, I personally created an environment that can be used as a webhook destination for general purposes.
The environment is AWS Lambda (and API Gateway) as the most familiar one.
The contents of the Lambda function are as follows, so that it can be output to the log regardless of whether it is received by POST or GET.
import json
def lambda_handler(event, context):
#Argument: Display the contents of event
print("Received event: " + json.dumps(event))
# rawQueryString
rawQueryString = event['rawQueryString']
if(len(rawQueryString) != 0):
queryStringParameters = event['queryStringParameters']
print(queryStringParameters)
# body
body = event.get('body')
if(not body is None):
json_body = json.dumps(body)
print(json_body)
return {
'isBase64Encoded': False,
'statusCode': 200,
'headers': {},
'body': json.dumps('Hello from Lambda!')
}
Recommended Posts