You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Marcelo Jara <ma...@hotmail.com> on 2013/03/05 19:12:57 UTC

JSON encoded URL problem

I am using a Regex Extractor to get a URL for the next step in the test plan. The Url will change whether the request was successful or not. Here is an example:
{"success":true,"successUrl":"/checkout/thankyou?email=77220130305125322mg07gkqup3%40blah.com\u0026order_number=541682470"}

I am extracting the URL correctly using 
successUrl":"(.*?)"   
However, when I try to use it in the next sampler, I get an error. Example:
https://server.test.com/checkout/thankyou?email=77220130305125322mg07gkqup3%40nook.com\u0026order_number=541682470
The error is 
java.net.URISyntaxException: Illegal character in query at index 85: https://uk.pe.nook.com/checkout/thankyou?email=77220130305125322mg07gkqup3%40nook.com\u0026order_number=541682470

I believe this is due to the JSON response which converted '&' to "\u0026" in the URL.
What's the best way to handle this? Do I need to use a Beanshell Preprocessor to substitute "\u0026" back to '&' ?

 		 	   		  

Re: JSON encoded URL problem

Posted by David Luu <ma...@gmail.com>.
I would think a preprocessor is best to deal with that. You could probably
JSON/URL decode that back into the original string in the preprocessor. It
doesn't have to be in Beanshell/Java, could be in Javascript with one of
the other preprocessors. Whatever is easiest to decode the string. Like in
PHP, there's a json_decode(str) method that will do that for you.

On Tue, Mar 5, 2013 at 10:12 AM, Marcelo Jara <ma...@hotmail.com>wrote:

> I am using a Regex Extractor to get a URL for the next step in the test
> plan. The Url will change whether the request was successful or not. Here
> is an example:
>
> {"success":true,"successUrl":"/checkout/thankyou?email=77220130305125322mg07gkqup3%
> 40blah.com\u0026order_number=541682470"}
>
> I am extracting the URL correctly using
> successUrl":"(.*?)"
> However, when I try to use it in the next sampler, I get an error. Example:
>
> https://server.test.com/checkout/thankyou?email=77220130305125322mg07gkqup3%40nook.com\u0026order_number=541682470
> The error is
> java.net.URISyntaxException: Illegal character in query at index 85:
> https://uk.pe.nook.com/checkout/thankyou?email=77220130305125322mg07gkqup3%40nook.com\u0026order_number=541682470
>
> I believe this is due to the JSON response which converted '&' to "\u0026"
> in the URL.
> What's the best way to handle this? Do I need to use a Beanshell
> Preprocessor to substitute "\u0026" back to '&' ?
>
>