Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ResponseObject' object has no attribute 'to_string' #240

Open
mi6crazyheart opened this issue Jul 15, 2023 · 0 comments
Open

'ResponseObject' object has no attribute 'to_string' #240

mi6crazyheart opened this issue Jul 15, 2023 · 0 comments

Comments

@mi6crazyheart
Copy link

I'm following this (https://www.plivo.com/docs/sms/quickstart/python-flask#api-send-your-first-outbound-sms-mms-message) doc for sending SMS. I'm using the exact source code(shared below), which has been mentioned in the doc. But when executing the "send_sms" endpoint, I get the following error.

File "/Users/skm/Documents/Projects/Python/Flask/sms/send_sms.py", line 17, in outbound_sms
    return Response(response.to_string())
                    ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ResponseObject' object has no attribute 'to_string'

Source code -

from flask import Flask, Response
import plivo

app = Flask(__name__)

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"

@app.route('/send_sms/', methods=['GET', 'POST'])
def outbound_sms():
    client = plivo.RestClient('<auth_id>','<auth_token>')
    response = client.messages.create(
    src='<sender_id>',
    dst='<destination_number>',
    text='Hello, from Flask!')
    return Response(response.to_string())

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

I'm using "Python 3.11.4"

dependencies in "requirements.txt"
blinker==1.6.2
certifi==2023.5.7
charset-normalizer==3.2.0
click==8.1.5
decorator==4.4.2
Flask==2.3.2
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
lxml==4.9.3
MarkupSafe==2.1.3
plivo==4.37.0
PyJWT==2.7.0
requests==2.31.0
six==1.16.0
urllib3==2.0.3
Werkzeug==2.3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant