I'm having a bit of trouble getting SmartSuite to deliver notifications to the endpoint I configured when setting up a webhook.
The events are logged correctly when I call ListEvents, and the endpoint is listed correctly in the webhook.notification_status.enabled.url parameter of the response to the webhook creation, but no events are being received at the configured endpoint. Am I doing something wrong?
Best reply by Peter Novosel
Adam Johnston I sent this to you personally but reposting here for the community's information.
Hi Adam, one of the known issues with the POST notifications sent to the configured endpoint is that they aren't including a Content-Type: application/json header. Depending on what you're catching them with, that might be an issue. โ For example, I was testing using Pythonanywhere - I've got a very basic flask app that was receiving webhooks, and I had to do it this way: โ
@app.route('/webhook', methods=['POST'])
def webhook():
# Get the complete headers from the received POST request
headers = str(request.headers)
# Read the request body as plain text
payload = request.data.decode('utf-8')
try:
payload_json = json.loads(payload)
payload = json.dumps(payload_json, indent=2) # Re-serialize as formatted JSON
except json.JSONDecodeError as e:
payload = f'Could not parse JSON: {str(e)}'
# Save the raw request data to the file
with open(raw_request_data_file, 'a') as file:
file.write(f'Headers:\n{headers}\nPayload:\n{payload}\n\n')
return 'Webhook received and saved successfully!'
I am discussing with the dev team to see when we can work in an update to the outbound POST. I'll keep you posted (no pun intended!)