Account: Free user
I am trying to send a message to my telegram chat using URL: https://api.telegram.org.
** This url is whitelisted for free users**
Below is the code which i have for the sending Telegram Message when running code with run command from pythonanywhere file editor everything works properly and iam able to get the response and message in telegram
import requests
from env import TELE_BOT_TOKEN as api_token
chat_id=158775078
def send_message(userName, emailId, message):
text = f"""*Name*: {userName}
*MailID*: {emailId}
*Message*:
{message}"""
url = f'https://api.telegram.org/bot{api_token}/sendMessage'
params = { 'chat_id':chat_id, 'text':text, 'parse_mode':'Markdown' }
try:
res = requests.get(url, params=params )
return res.__dict__
except requests.exceptions.RequestException as e:
print(e)
return 404
if __name__ == "__main__":
print(send_message("vimal", "vimal@gmail.com", "test"))
My Api endpoint When calling via API am not able to get the response and the error message in console is not helping me much
@api.post('/sendmsg')
def send_tele_msg():
username, emailid, message = request.json.get('userName'), request.json.get('emailId'), request.json.get('message')
print(request.__dict__)
print(username, emailid, message)
msg = telebot.send_message(**request.json)
return {'status': True}
when trying from postman got the error
Error code: 504-loadbalancer
Kindly help me to resolve the issue. Same code is working properly in my local Machine