Textlocal URL shortner API does not work with signed url

102 views Asked by At

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)
1

There are 1 answers

0
Jasmine On

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