Skip to content
Advertisement

Unable to send sms on whatapp throguht route

bascially i am making a route in which i have connect my api of whatapp when i send a number in my json response thought software this route should send me a whatapp message on that number

@app.route('/v1.1/userRegistor', methods=['POST','GET'])
def get_user():
    data = request.get_json()
    numbers=data['numbers']
    api_url = ('https://app.simplywhatsapp.com/api/send.php?number=numbers&type=text&message=test%20message&instance_id=634CF8BECCB26&access_token=78495efca3672167f9ed88cb93acd2e1')
    r = requests.get(api_url)
    return r.json()

this is my request body: {

"numbers":"923142985338"

}

Advertisement

Answer

You aren’t formatting your API request URL. The variables can’t be passed directly in the string, as they can’t be distinguished from words. You need to use a format string.

api_url = f'https://app.simplywhatsapp.com/api/send.php?number={numbers}&type={text}&message=test%20message&instance_id=634CF8BECCB26&access_token=78495efca3672167f9ed88cb93acd2e1'

Read more about it here: https://www.pythoncheatsheet.org/cheatsheet/string-formatting

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement