Nick
Nick

Reputation: 771

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?

Upvotes: 1

Views: 2438

Answers (2)

riorio
riorio

Reputation: 6816

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

Upvotes: 1

Slava Vedenin
Slava Vedenin

Reputation: 60104

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 "://".

Upvotes: 0

Related Questions