Return pdf file thorugh api

I am trying to get the pdf file from decoded base64 but i am getting the following response

My api code

@app.route('/hello', methods=['GET'])
def hello(request):
    pdf="JVBERi0xLjMKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggN..."
    pdf_data = base64.b64decode(pdf)
    return pdf_data

my response

"id": 291,
    "result": {
        "__class__": "bytes",
        "base64": "JVBERi0xLjMKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29k\nZT4+CnN0cmVhbQp4nMy9eTyU6/8/fo+xjilKWVJR2lNmxhijZFQnbaTlVDqUJUuLEopEBiUtJJUQ\nNarTrrJUEhkie6mULRkSkn0dY5b7d49iOtx3X96/mfM5533/MY/3ebjP835dr+v1fL2u1/O6Lmd1\n3EI8QR3H/9/Aj537MFobddUdXDHOGJw6iYTDqe/DaOvq/Pjp+OMnkawH/cQN/NiF2aq+H9P/GvWN\nK3/+cHHAbIDeMfin+zBEgt7AW/p//vjjX16I9B5nDHmhNv+f/v/j198796kv+xMCTFbH4xfiiOp/\n2mNwC/X0yDiybv+/x6sTddR1yfiFJLL6n/swc1Bz/9yDWfEnhGxD//fpkKF/QSSTIDQE6D9lp751\nHoTAWZ3Y/9cEdSJRD/pKbT0S3y7LVmO0lm/S2rhyGUZrqzoBo7VKHY/RWrZ+uToZs/oP9Yi0iIup\nFzErVqtD71YnDbxBh4j0Bu2hb7ide+vCi/NXM6IGXkIQ4NAl8t9CHP4W/D+BaBlpGTlitP5Yr6+v\ntd7Fznb3zoNOLup4HehPnBwP7dvv2v8H0G8nF1d1bQMD/n/3cNTOqENWxezWVoo3u62aHcC0ZIDW\nfRk5mb0gg3oCxBqmZWbaatphgXINhfzh4HS0ySIFV2AZAjblbzpBBVWUlZeeC2lnMKhRBVFiFmJi\nUWLLKpZxLDgA7wIGNYiMLDBbv/"
 }
}

If you return raw data, depending on the ACCEPT-MIMETYPES of the request, trytond may consider it as a JSON-RPC response (your behavior) or just a JSON request (encoded in base64).
In order to avoid such encoding, you must return a werkzeug Response (and probably fill the right mimetype).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.