0

Python + Flask + Requests を使用して別の API を使用するためのコードを記述しているときに問題が発生しています。RAW JSONの代わりにx-www-form-urlencodedでPHPを使用するAPI、ここに私のコードがあります:

app = Flask(__name__)

@app.route('/api/test/getinfo', methods=['POST'])
def get_house_info():
    if request.method == 'POST':
        try:
            payloads = {'no_house':'001234123', 'cd_agent' : '01', 'nm_agent' : 'ABC'}          
            response_data = requests.post(url=url, headers=headers, data=payloads)
            return response_data
        except Exception as e:
            return(str(e))

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True)

その後、このフラスコを実行し、郵便配達員を使用してこのエンドポイントを呼び出そうとしましたが、エラーObject of type Response is not JSON serializable を受け取りました コードに何か問題がありますか?

4

1 に答える 1