twilio Handle a SMS StatusCallback and get all values from request in flask / python

Question:

i need to retrive twilio SMS StatusCallback json, but i have problem to take all values in a single json from twilio.

i follow this example https://www.twilio.com/docs/sms/tutorials/how-to-confirm-delivery-python?code-sample=code-handle-a-sms-statuscallback-1&code-language=Python&code-sdk-version=6.x

i try to improve with request.get_json() but i recive None values. it’s work if i specify with value with requests.values.get

@app.route("/MessageStatus", methods=['POST'])
def incoming_sms():

    message_sid = request.values.get('MessageSid', None)
    message_status = request.values.get('MessageStatus', None)
    logging.info('SID: {}, Status: {}'.format(message_sid, message_status))
    print(request.get_json())


    return ('', 204)

thank you a lot!

Asked By: Marco Scarselli

||

Answers:

print(json.dumps(request.values.to_dict()))

Answered By: Smart Manoj
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.