You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to send a message in another language with a line break using the send method, an error occurred: HTTP error: BadStatusLine def send(self, chat_id, text): data = {'chat_id': chat_id, 'text': text} try: headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} url = f"{self.url}/sendMessage?chat_id={chat_id}&text={str(text).replace('\n', '%0A')}" response = urequests.post(url, headers=headers) response.close() return True except Exception as e: print("Error:", e) return False
In this code, I replaced the \n line breaks with URL-encoded %0A characters when generating the message body to be sent. This will help avoid problems with HTTP headers and request structure.
The text was updated successfully, but these errors were encountered:
When trying to send a message in another language with a line break using the send method, an error occurred: HTTP error: BadStatusLine
def send(self, chat_id, text): data = {'chat_id': chat_id, 'text': text} try: headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} url = f"{self.url}/sendMessage?chat_id={chat_id}&text={str(text).replace('\n', '%0A')}" response = urequests.post(url, headers=headers) response.close() return True except Exception as e: print("Error:", e) return False
In this code, I replaced the \n line breaks with URL-encoded %0A characters when generating the message body to be sent. This will help avoid problems with HTTP headers and request structure.
The text was updated successfully, but these errors were encountered: