How to take URL encoded queryy parameter as Input to queryParams method

2,425 views
Skip to first unread message

Anurag Gupta

unread,
May 24, 2017, 3:10:49 AM5/24/17
to REST assured
Hi ,

We are automating REST services by REST assured and are developing a framework for the same . In your Java doc I find a way to handle url encoded querry parameters like below .

String response = given().urlEncodingEnabled(false).get("https://jira.atlassian.com:443/rest/api/2.0.alpha1/search?jql=project%20=%20BAM%20AND%20issuetype%20=%20Bug").asString();
..


what we are doing here is we are passing full URI as input to get method .

But we want to use queryParam method instead of passing full URI so that we can parameterize it later according to requirement . It should be something like 


String uriPath="/rest/api/2.0.alpha1/search";
RestAssured.baseURI=""https://jira.atlassian.com:443";
String response = given().urlEncodingEnabled(false).and().given().queryParam("","").and().given().get().asString();



I am not sure what to pass in queryParam if query param is encoded as : ?jql=project%20=%20BAM%20AND%20issuetype%20=%20Bug


Kindly help 

Warm Regards 
Anurag Gupta


Johan Haleby

unread,
May 24, 2017, 4:25:58 AM5/24/17
to rest-a...@googlegroups.com
Hmm it doesn't look like ONE query parameter to me since "=" is not url encoded?
 


Kindly help 

Warm Regards 
Anurag Gupta


--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anurag Gupta

unread,
May 24, 2017, 5:42:33 AM5/24/17
to REST assured
Sharing you exact requirement

...

Query Parameters

Encoded URL

Decoded URL

Filter (Mandatory):

filters=recommendationFor.id%3D%3D5552681_5556861%26recommendedOffering.type%3D%3DaccessoryOffering

filters=recommendationFor.id==5552681_5556861&recommendedOffering.type==accessoryOffering


Is there any way to send encoded url  as query parameter by queryPram method or I have to directly use uri as string ?

To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.

Johan Haleby

unread,
May 24, 2017, 5:55:33 AM5/24/17
to rest-a...@googlegroups.com
On Wed, May 24, 2017 at 11:42 AM, Anurag Gupta <anura...@gmail.com> wrote:
Sharing you exact requirement

...

Query Parameters

Encoded URL

Decoded URL

Filter (Mandatory):

filters=recommendationFor.id%3D%3D5552681_5556861%26recommendedOffering.type%3D%3DaccessoryOffering

filters=recommendationFor.id==5552681_5556861&recommendedOffering.type==accessoryOffering


Is there any way to send encoded url  as query parameter by queryPram method or I have to directly use uri as string ?

That looks better! You should be able to do:

given().urlEncodingEnabled(false).queryParam("filter", "recommendationFor.id%3D%3D5552681_5556861%26recommendedOffering.type%3D%3DaccessoryOffering"). ..



On Wednesday, May 24, 2017 at 1:55:58 PM UTC+5:30, Johan Haleby wrote:

On Wed, May 24, 2017 at 9:10 AM, Anurag Gupta <anura...@gmail.com> wrote:
Hi ,

We are automating REST services by REST assured and are developing a framework for the same . In your Java doc I find a way to handle url encoded querry parameters like below .

String response = given().urlEncodingEnabled(false).get("https://jira.atlassian.com:443/rest/api/2.0.alpha1/search?jql=project%20=%20BAM%20AND%20issuetype%20=%20Bug").asString();
..


what we are doing here is we are passing full URI as input to get method .

But we want to use queryParam method instead of passing full URI so that we can parameterize it later according to requirement . It should be something like 


String uriPath="/rest/api/2.0.alpha1/search";
RestAssured.baseURI=""https://jira.atlassian.com:443";
String response = given().urlEncodingEnabled(false).and().given().queryParam("","").and().given().get().asString();



I am not sure what to pass in queryParam if query param is encoded as : ?jql=project%20=%20BAM%20AND%20issuetype%20=%20Bug

Hmm it doesn't look like ONE query parameter to me since "=" is not url encoded?
 


Kindly help 

Warm Regards 
Anurag Gupta


--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.

Anurag Gupta

unread,
May 24, 2017, 7:16:41 AM5/24/17
to REST assured
Thanx Johan ,
Reply all
Reply to author
Forward
0 new messages