1

I am using the textlocal short url API with the signed URL that I have generated for a Cloud Storage blob. I am getting MalformedSecurityHeader error in the browser when I use the short URL. I tried the same API with other random links and it worked fine. Can I get some help on this.

def shorten_url(apikey, url):
   data =  urllib.parse.urlencode({'apikey': apikey, 'url': url})
   data = data.encode('utf-8')
   request = urllib.request.Request("https://api.textlocal.in/create_shorturl/")
   f = urllib.request.urlopen(request, data, 
   context=ssl.create_default_context(cafile=certifi.where()))
   fr = f.read()
   return(fr)
Jasmine
  • 476
  • 3
  • 22

1 Answers1

1

I was able to resolve this. data = urllib.parse.urlencode({'apikey': apikey, 'url': urllib.parse.quote(url)})

Jasmine
  • 476
  • 3
  • 22