简体   繁体   中英

How to pass an url by a rest api URL string

I have a table a with columns like pageId and page_name where values are inserted line [1,https://google.com] and so on.

Now i created an api that takes the URL and returns the pageid, so now the scenario is like:

localhost:8080/api/v1/page/https://google.com

whenever i am trying to pass it via Postman is is showing Could not send response can anyone help me to fix this problem?

The problem is that you have reserved chars in your query param.

Consider encoding your text.

So: http://www.google.com

will become: http%3A%2F%2Fwww.google.com

 localhost:8080/api/v1/page/https://google.com

According url format documentation (see for example this article )- impossible use reserved chars (: and /) as parameters. I reccoment use something like

localhost:8080/api/v1/page/google.com

And add "https://" in service

or use

localhost:8080/api/v1/page/https~~google.com

And replaced "~~" to "://".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM