This is probably the weirdest error I have ever run into and I have spend the past 48 hours trying to figure out a solution. Basically I have a Flask application that I have been developing for the past year and a half. Everything works, except for one of my final tasks. I am trying to integrate Elasticsearch with the application and so far everything has worked on my local machine (Mac OS X Catalina). However, when I put the same code on the server, (DigitalOcean CentOS 7), it fails.
Specifically I am trying to get json data and incorporate it in my search string which is passed to Elasticsearch. The relevant code is below:
from flask import request, g, Blueprint, json, Response, current_app, url_for
@search_api.route('/', methods=['POST'])
@jwt_required
def search():
"""
Full text search against user and events models
"""
req_data = request.get_json()
I have used very similar code in 60+ other API endpoints, and none are functioning incorrectly. The weirdest thing is it works on localhost. I have even done print statements and I can verify that request.get_json() is returning an empty dict. However, that is only on the remote box, not the local machine.
This is a bug that I cannot seem to fix, so hopefully someone might have seen this before and can point me in the right direction. Flask version is 1.0.2.
I am making the requests with Postman. I have tried cURL and that returns the same error as well.
EDIT: Forgot to add the error:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
That error is directly related to request.get_json() not getting any data. I print the contents of that dict is empty. So the issue is the json is not being passed to the function.