Flask post and put requests giving 400 bad request with sentry

Hi,

I configured sentry in my flask app. After that any error that was generated was getting posted to my account without any issue. But, all the PUT and POST requests are returned with 400 bad request. When sentry configuration and initialisation is commented out, it works properly. My flask app is using nginx as well and as per the documentation I had changed my nginx settings by providing proxy_pass header and also using ProxyFixer to set app.wsgi_app. But none of these changes are fixing the actual issue.

Sentry does not change any of the request lifecycle of your app. If you take the exact config and ONLY disable the init_app call on the Sentry object what happens?

The init_app code is commented as of now. So, sentry is not currently active in the flask project. But, if I uncomment it like below :

     sentry = Sentry(app, dsn='https://****:****@sentry.io/NNNNN')
     sentry_config = app.config.get('SENTRY_CONFIG')
     if sentry_config:
          sentry_config['environment'] = config_name

Sentry now gets initialized. When this happens the below line
data = request.get_json(True)

fails and I get Bad Request exception.

If the request’s content-type is made : application/json the above problem is resolved. But, if that is not the case, it still persists. Please refer this link which explains the same problem. https://github.com/pallets/flask/issues/1786

What should we be doing for requests where application/json cannot be given as content-type ?