Describe the bug
I'm using the u.nu service which uses Yourls as its backend. With the particular link I am using the website form will work correctly and create a shorted link. However, when I use the API it can't seem to follow the link correctly. Website form produces the link https://u.nu/awdm which is correct. API produces the link https://u.nu/9x0- which is incorrect. Why should it be different?
Please note that these links are password protected.
Link with API:
https://u.nu/api.php?action=shorturl&format=simple&url=http://esgms/niku/app?action=union.viewODFFile&fileId=10372727&versionId=10372728&odf_pk=5348166&objectType=gm_app_attachment&RhXm0r7tSeUqEr=true
You need to URL-encode the url parameter you send to the API, or any ? and & characters in it will create extra parameters to the API (which it will ignore) instead of being part of the URL you want to shorten.
Replace all ? with %3F and all & with %26, then your API call should work as expected. You might also need to encode more characters; see if there is a urlencode() or similar function available to you (from language framework or wherever).
Thanks. That's perfect.
Most helpful comment
You need to URL-encode the
urlparameter you send to the API, or any?and&characters in it will create extra parameters to the API (which it will ignore) instead of being part of the URL you want to shorten.Replace all
?with%3Fand all&with%26, then your API call should work as expected. You might also need to encode more characters; see if there is aurlencode()or similar function available to you (from language framework or wherever).