Cant enable webhook in python

Hi,

Im trying to enable a webhook in python with this code, but Im just having this error :

disabledDetails": "Response was missing verification response in both header and body, or body JSON may have been invalid. (ref id: latvtu)", "enabled": false

in that sense, I think that the callback url is well configured because when I runing the previous code to activate the webhook, an aws lambda function is triggered that has that url created in aws´s apigateaway which gives this log



As you can see it, the Smartsheet-Hook- Response is not in the header that the webhook sent, however I run this code in aws lambda that should handle that case that the challenge is not in that header but in the body, :

import json

def lambda_handler(event, context):
print("Evento completo recibido:", json.dumps(event))

if "challenge" in event:


challenge = event.get("challenge")

# Respond to verification challenge

return {
"statusCode": 200,
"headers": {
"Content-Type": "application/json",
"Smartsheet-Hook-Response": challenge # Enviar desafío en el encabezado
},
"body": json.dumps({"smartsheetHookResponse": challenge})


print("Respuesta enviada:", json.dumps(response))

return {
'statusCode': 200,
'body': 'Data received and processed successfully

but It did not work either, can any of you could guide me how to solve this. I tried another version of that code that I saw on internet but cant reach a solution.

grateful in advance.

greetings.

Tags:

Answers