Sending Post request to Flask restAPI using python give response Error 500 [duplicate]

Solution
import json

@app.route("/predict", methods=["POST"])
def predict():
    data = json.loads(request.get_data())
    print(data)
data = {"A":123, "B":22, etc...}
url_path = 'http://127.0.0.1:5000/predict'
response = requests.post(url_path, json=json.dumps(data))