Yourls: Differences between a webform and API

Created on 25 Dec 2018  路  2Comments  路  Source: YOURLS/YOURLS

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:
http://esgms/niku/app?action=union.viewODFFile&fileId=10372727&versionId=10372728&odf_pk=5348166&objectType=gm_app_attachment&RhXm0r7tSeUqEr=true

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

question

Most helpful comment

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

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alan-Liang picture Alan-Liang  路  6Comments

jonathandhn picture jonathandhn  路  6Comments

federico-galli picture federico-galli  路  3Comments

youradds picture youradds  路  3Comments

lkuza2 picture lkuza2  路  3Comments