Webhook processing with bitrix24 in Python Flask

I don't understand what the problem is at all. It is necessary to process the webhook with Bitrix 24. But I get the HttpStatus.BAD_REQUEST error. Can someone help, and then the deadline is burning) Here is the code:

import requests
import json
from flask import Flask
from flask import request

app = Flask(__name__)


@app.route('/', methods = ['POST', 'GET'])
def index():
    if request.method == 'POST':
         r = request.get_json()
         print(r)

return '<h1>hello world</h1>'

if __name__ == '__main__':
    app.run()

Here is the error that gives:

"¦¢¥£)>K¾+6Þ¿6Ø{vÓÄ0HAb"

Author: Froot, 2020-05-26

2 answers

For an outgoing web hook with the event creating a task I used:

@app.route('/', methods=['POST'])
def result():
    print(request.form)
    return 'OK'
 1
Author: Violet, 2020-05-26 13:56:25

I figured out how I understood Bitrix sends webhooks on port 80, so you should just change the port to 80. But also after that, you should configure ngix in order to avoid trouble) This code also helped:

@app.route('/', methods=['POST'])
def result():
     print(request.form)
     return 'OK'
 0
Author: Froot, 2020-05-27 08:20:03