Why is this a "Invalid Parameter: URL argument was malformed URL"?

When I call network.download(), my URL is (mixed with some Chinese characters since it is retrieved from an outside source at runtime)

http://cdn.unwire.hk/wp-content/uploads/2013/09/Xiaomi2013-Keynote-PDF-20130905.pdf(頁面\_21∕215)-590x382.jpeg

My console log shows “Invalid Parameter: URL argument was malformed URL”

However, this URL is actually good if I post it to a browser, the jpg is shown.

Is there anything I can do to “render” the URL above to make it good for Corona to process it? (Please note that the URLs I am using are retrieved from outside dynamically, changing the format of the URLs is beyond my control) 

If the URL is good to the browsers, I wonder why Corona considers invalid?

Your URL is malformed.  It works in the browser because the browser is stripping the (頁面_21∕215) and the -590x382.jpeg.  URL parameters must be passed as query strings.  I’m not sure what the two Chinese characters are but normally parameters look like:

http://cdn.unwire.hk/wp-content/uploads/2013/09/Xiaomi2013-Keynote-PDF-20130905.pdf?somekey=someval&someotherkey=someotherval

Spaces, and special symbols are required to be URL encoded.  Now to be honest, it looks like you just copied the string from a webpage and got aggressive with the amount of text to copy.  If all you want is to download that PDF documents, leave off everything after the .pdf.

Actually there is no space in the URL I posted above.

The left and right Parenthesis in “(頁面_21∕215)” are in Chinese format and take two characters, so it looks like there are spaces before and after. However, if you use mouse to select the parenthesis, you will see there isn’t any space. These Chinese characters are just normal characters inside an URL. The URL I posted is actually a valid URL.

If you copy the URL to a browser, you will see the browser is not stripping anything. Besides, the URL is meant to get the jpg, not the pdf. The browser shows the jpg image file correctly.

Well I’m sure the Chinese characters still need URL encoded and perhaps the browser is protecting you by encoding it before it sends it.

Urlencoding everything after directory name works: 

http://cdn.unwire.hk/wp-content/uploads/2013/09/Xiaomi2013-Keynote-PDF-20130905.pdf%EF%BC%88%E9%A0%81%E9%9D%A2_21%E2%88%95215%EF%BC%89-590x382.jpeg

Online url encoder for testing: http://meyerweb.com/eric/tools/dencoder/

Rob & Jon, thanks a lot for your help.

I think I got it.

Your URL is malformed.  It works in the browser because the browser is stripping the (頁面_21∕215) and the -590x382.jpeg.  URL parameters must be passed as query strings.  I’m not sure what the two Chinese characters are but normally parameters look like:

http://cdn.unwire.hk/wp-content/uploads/2013/09/Xiaomi2013-Keynote-PDF-20130905.pdf?somekey=someval&someotherkey=someotherval

Spaces, and special symbols are required to be URL encoded.  Now to be honest, it looks like you just copied the string from a webpage and got aggressive with the amount of text to copy.  If all you want is to download that PDF documents, leave off everything after the .pdf.

Actually there is no space in the URL I posted above.

The left and right Parenthesis in “(頁面_21∕215)” are in Chinese format and take two characters, so it looks like there are spaces before and after. However, if you use mouse to select the parenthesis, you will see there isn’t any space. These Chinese characters are just normal characters inside an URL. The URL I posted is actually a valid URL.

If you copy the URL to a browser, you will see the browser is not stripping anything. Besides, the URL is meant to get the jpg, not the pdf. The browser shows the jpg image file correctly.

Well I’m sure the Chinese characters still need URL encoded and perhaps the browser is protecting you by encoding it before it sends it.

Urlencoding everything after directory name works: 

http://cdn.unwire.hk/wp-content/uploads/2013/09/Xiaomi2013-Keynote-PDF-20130905.pdf%EF%BC%88%E9%A0%81%E9%9D%A2_21%E2%88%95215%EF%BC%89-590x382.jpeg

Online url encoder for testing: http://meyerweb.com/eric/tools/dencoder/

Rob & Jon, thanks a lot for your help.

I think I got it.