Rest Assured – Query Parameter vs. Path Parameter

Learn about the differences between Query Parameter and Path Parameter

Rest Assured – Query Parameter vs. Path Parameter

What is Query Parameter in Rest API?

We can use query parameters to control what data is returned in endpoint resources. It appears at the end of the URL after the question mark (?) and helps us to control the set of items and properties in responses, and the order of the items returned.

Consider the following GitHub API URL:

https://api.github.com/user/repos?sort=created&direction=desc

This will list all repositories for an authenticated user but the response properties will be sorted by repository created and in descending order.

There are two query parameters defined in the API url:

– sort=created (sort repositories by created date)

– direction=desc (sort in descending order)

What is Path Parameters in Rest API?

Path parameters are variables in a URL path. They are used to point to a specific resource within a collection. We can define multiple PATH parameters and each of them is represented by a curly brace {}.

Consider the following GitHub API url:

https://api.github.com/users/:username/repos

This will list all public repositories for the specified user with the value username.

:username is the Path parameter in the above url.

How to pass Query Parameter and Path Parameter using Rest Assured?

Bijan Patel
Full Stack Test Automation Expert | Selenium Framework Developer | Certified Tosca Automation Specialist | Postman | DevOps | AWS | IC Agile Certified | Trainer | Youtuber | Blogger|

Launch your GraphyLaunch your Graphy
100K+ creators trust Graphy to teach online
𝕏
QASCRIPT 2024 Privacy policy Terms of use Contact us Refund policy