Illegal character in query at index 138:

I am using rest-assured to automate a Rest Get Call and getting below error:
Illegal character in query at index 138:

try {
			result = java.net.URLEncoder.encode("http://localhost:8080/", StandardCharsets.UTF_8.name());
		} catch (UnsupportedEncodingException e) {
			System.out.println("xyz");
		}
request= given().log().all().spec(requestHeader_abc())
				.queryParam("response_type", "code")
				.queryParam("client_id","***7")
				//.queryParam("redirect_uri", encodeValue("http://localhost:8080/"))
				.urlEncodingEnabled(false).queryParam("redirect_uri", "http://localhost:8080/")
				//.queryParam("redirect_uri", result)
				.queryParam("max_age",0)
				.queryParam("scope","profile p1:read:user");

response = request.when()
						.get(pingResources.getResources())
						.then()
						.log().all()
						.extract().response();

Error: Caused by: java.net.URISyntaxException: Illegal character in query at index 138:

What could be possible fix, am I handling"redirect_uri" wrongly??

Welcome to the developer community Varsha.

You could try manually encoding the : and / characters using % encoding.

Thanks Colin! But after using urlEncodingEnabled(false) method, where should I use " manually encoding the : and / characters using [% encoding ]" ?
Also can u please explain it with an example? I am very new to rest assured

% encoding is what URL encoding is supposed to do, but it appears that isn’t working correctly in this case. To do it manually, you just need to do the following:


request= given().log().all().spec(requestHeader_abc())
				.queryParam("response_type", "code")
				.queryParam("client_id","***7")
				.queryParam("redirect_uri", "http%3A%2F%2Flocalhost%3A8080%2F")
				.queryParam("max_age",0)
				.queryParam("scope","profile p1%3Aread%3Auser");

response = request.when()
						.get(pingResources.getResources())
						.then()
						.log().all()
						.extract().response();