HTTP GET Method – Ways to form GET URL

HTTP GET Method – Ways to form GET URL

In this article let us see the ways to form GET URL for http requests. We are going to use Spring Boot and Google Chrome Postman to verify the URL formation.

Common ways of forming GET url’s are by

  1. Path
  2. Body

Query: (Path)

When GET URL is formed along with query, the URL will look like,

http://example/{id}

Params: (Body)

When GET URL is formed along with Params, we will send the parameters along with the body.

http://example?id=1

There are four parameters with request param,

  • defaultValue – This is the default value, if the request is not having the value or it is empty.
  • name – Parameter name
  • required – true, if we want to make the parameter required one.
  • value – value of the parameter

Now let us see an example – Various ways to form GET URL.
I have created a simple springboot application with a controller. The output shown below are from chrome postman application.

you can download the code here

Output:
/javainfinite

 

/javainfinite/{id}


/javainfinite/idParam

/javainfinite/params

/javainfinite/uriComponentBuild

/javainfinite/uriBuild

 

Download here

 

Read More