0

I am getting Url can't contain special character.{the whole url with mobile number and otp in it} (found at least ' ') errror. Please help

'''

def send_otp(mobile , otp):

print("FUNCTION CALLED")
conn = http.client.HTTPSConnection("api.msg91.com")
authkey = settings.AUTH_KEY 
headers = { 'content-type': "application/json" }
url = "http://control.msg91.com/api/sendotp.php?otp="+otp+"&message="+"Your otp is "+otp +"&mobile="+mobile+"&authkey="+authkey+"&country=91"

conn.request("GET", url , headers=headers)
res = conn.getresponse()
data = res.read()
print(data)
return None

'''

  • You need to add them as query params, and encode special characters. [Add params to given URL in Python](https://stackoverflow.com/questions/2506379/add-params-to-given-url-in-python) – Abhinav Mathur Mar 14 '22 at 06:07
  • i am unable to understand anything from the link you provided. Could you tell me how, Please? –  Mar 16 '22 at 11:59
  • Look up "query items" and "path parameters" for URLs, then search special characters in URLs. Long story short, the `url` variable you're constructing is wrong – Abhinav Mathur Mar 16 '22 at 12:01

0 Answers0