Using URL Encoded values in a JMeter variable in a HTTP POST

View: New views
11 Messages — Rating Filter:   Alert me  

Using URL Encoded values in a JMeter variable in a HTTP POST

by Richard Gaywood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list! Encountered a problem with JMeter (v2.3.4) that I cannot find a workaround for. Hoping someone has a suggestion I've overlooked.

I have a complicated HTTP POST request (70+ parameters, with a number of variable substitutions). I've coded it up but encountered a problem with eleven parameters that were just GUID name/value pairings. Some work with a regular expression extractor, a Beanshell sampler, and a ForEach controller has constructed these into a single JMeter variable with the usual "name=value&name=value&name=value&" (etc) structure.

My problem is, JMeter is insisting in URL encoding the JMeter variable contents when I put it in the "send parameters with the request" section, regardless of how I tick or untick the "encode?" column. I found this old post by sebb:

On Mon, Oct 8, 2007 at 7:40 PM, sebb <sebbaz@...> wrote:
OK, in that case I think there is a work-round.

If you use parameters with values but *no names*, then HttpClient (and
Java http) will include the values in the POST body as is with no
encoding or equals signs.

(This does not appear to be documented anywhere ... oops!)
 
But this only seems to work when I only have one single line in the request parameters config. As soon as I mix the workaround with normally encoded parameters, JMeter stops working. See my screenshot -- where I set two parameters; the first a JMeter variable containing the string "name=value&spam=eggs" and the other a normal parameter with name "ham" and value "green". When I hit send, the POST parameters look like:
        POST data:
        ham=green
...with no mention of the other two parameters.

So... is there a workaround for this? Or do I need to manually URL encode my 60-odd parameters and put them all in a single Value box of my HTTPClient?




---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@...
For additional commands, e-mail: jmeter-user-help@...

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Deepak Shetty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
a. When you say URL encode do you mean the %nn for non ascii characters or
the & encoded as & (because these are HTML encoded to escape & and need
to be dealt with differently).
What does the source actually have? If the source html on which you are
running your regex to extract data , is already encoded , then checking or
unchecking the checkbox will appear to have to no effect (it might get
double encoded). can you add Debug samplers to check whether the data you
are extracting out is correct or already encoded?
b. Checking or Unchecking the encode value does work, you can try it
standalone with a hardcoded string which has special characters like = or +

regards
deepak


On Mon, Nov 9, 2009 at 6:51 AM, Richard Gaywood <richardgaywood@...>wrote:

> Hi list! Encountered a problem with JMeter (v2.3.4) that I cannot find a
> workaround for. Hoping someone has a suggestion I've overlooked.
>
> I have a complicated HTTP POST request (70+ parameters, with a number of
> variable substitutions). I've coded it up but encountered a problem with
> eleven parameters that were just GUID name/value pairings. Some work with a
> regular expression extractor, a Beanshell sampler, and a ForEach controller
> has constructed these into a single JMeter variable with the usual
> "name=value&name=value&name=value&" (etc) structure.
>
> My problem is, JMeter is insisting in URL encoding the JMeter variable
> contents when I put it in the "send parameters with the request" section,
> regardless of how I tick or untick the "encode?" column. I found this old
> post by sebb:
>
> On Mon, Oct 8, 2007 at 7:40 PM, sebb <sebbaz@...> wrote:
>
>> OK, in that case I think there is a work-round.
>>
>> If you use parameters with values but *no names*, then HttpClient (and
>> Java http) will include the values in the POST body as is with no
>> encoding or equals signs.
>>
>> (This does not appear to be documented anywhere ... oops!)
>>
>
> But this only seems to work when I only have one single line in the request
> parameters config. As soon as I mix the workaround with normally encoded
> parameters, JMeter stops working. See my screenshot -- where I set two
> parameters; the first a JMeter variable containing the string
> "name=value&spam=eggs" and the other a normal parameter with name "ham" and
> value "green". When I hit send, the POST parameters look like:
>         POST data:
>         ham=green
> ...with no mention of the other two parameters.
>
> So... is there a workaround for this? Or do I need to manually URL encode
> my 60-odd parameters and put them all in a single Value box of my
> HTTPClient?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@...
> For additional commands, e-mail: jmeter-user-help@...
>

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Richard Gaywood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Deepak! Thanks for your response.

To clarify what I'm doing: my source page contains a number of tags like
this:

<input value="a7684624-aa9d-4bdd-be3c-97e8d67485d4"
name="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1" type="radio" id="[snip]"
CssClass="rdbtn" GroupName="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1"
checked="checked" />

I am grabbing them with this regexp:

<input
value="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12})"
name="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12}_1)".*?checked="checked"

and then using a ForEach controller and a beanshell sampler to build the
following string contained in a JMeter variable:

d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&
[etc etc]

This string contains the = and & signs you would expect to see in a POST
body. But when JMeter sends this, it URI encodes those characters, so it
ends up sending:

a602b71a-95ab-4046-8b24-8454a6d8a295_1%3Dc8635002-86a7-4841-9d8d-68bd375b1236%26b212fb47-6261-4f74-b8bc-8c7b331ed21a_1%3D4bba8a26-5542-43ef-b8e3-f57a0e95d7b7%26a3cdbda4-ea65-4a0a-95b0-99b94fb782de_1
[etc etc]

Note that & has become %26 and = has become %3D. Then, of course, the web
service I'm calling doesn't seen all those name=value pairs, it just sees a
single parameter. This happens when the "encode?" tickbox on the HTTPRequest
is ticked _or_ unticked.

On Mon, Nov 9, 2009 at 5:14 PM, Deepak Shetty <shettyd@...> wrote:

> Hi
> a. When you say URL encode do you mean the %nn for non ascii characters or
> the & encoded as & (because these are HTML encoded to escape & and need
> to be dealt with differently).
> What does the source actually have? If the source html on which you are
> running your regex to extract data , is already encoded , then checking or
> unchecking the checkbox will appear to have to no effect (it might get
> double encoded). can you add Debug samplers to check whether the data you
> are extracting out is correct or already encoded?
> b. Checking or Unchecking the encode value does work, you can try it
> standalone with a hardcoded string which has special characters like = or +
>
> regards
> deepak
>
>
> On Mon, Nov 9, 2009 at 6:51 AM, Richard Gaywood <richardgaywood@...
> >wrote:
>
> > Hi list! Encountered a problem with JMeter (v2.3.4) that I cannot find a
> > workaround for. Hoping someone has a suggestion I've overlooked.
> >
> > I have a complicated HTTP POST request (70+ parameters, with a number of
> > variable substitutions). I've coded it up but encountered a problem with
> > eleven parameters that were just GUID name/value pairings. Some work with
> a
> > regular expression extractor, a Beanshell sampler, and a ForEach
> controller
> > has constructed these into a single JMeter variable with the usual
> > "name=value&name=value&name=value&" (etc) structure.
> >
> > My problem is, JMeter is insisting in URL encoding the JMeter variable
> > contents when I put it in the "send parameters with the request" section,
> > regardless of how I tick or untick the "encode?" column. I found this old
> > post by sebb:
> >
> > On Mon, Oct 8, 2007 at 7:40 PM, sebb <sebbaz@...> wrote:
> >
> >> OK, in that case I think there is a work-round.
> >>
> >> If you use parameters with values but *no names*, then HttpClient (and
> >> Java http) will include the values in the POST body as is with no
> >> encoding or equals signs.
> >>
> >> (This does not appear to be documented anywhere ... oops!)
> >>
> >
> > But this only seems to work when I only have one single line in the
> request
> > parameters config. As soon as I mix the workaround with normally encoded
> > parameters, JMeter stops working. See my screenshot -- where I set two
> > parameters; the first a JMeter variable containing the string
> > "name=value&spam=eggs" and the other a normal parameter with name "ham"
> and
> > value "green". When I hit send, the POST parameters look like:
> >         POST data:
> >         ham=green
> > ...with no mention of the other two parameters.
> >
> > So... is there a workaround for this? Or do I need to manually URL encode
> > my 60-odd parameters and put them all in a single Value box of my
> > HTTPClient?
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@...
> > For additional commands, e-mail: jmeter-user-help@...
> >
>

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Deepak Shetty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

ok before I try it out since that will take time, when i had something
similar to do,
I just used a BeanShell preprocessor and used sampler.addArgument instead of
forming a string and trying to send the post body, see if it works for you
regards
deepak



On Mon, Nov 9, 2009 at 9:49 AM, Richard Gaywood <richardgaywood@...>wrote:

> Hi Deepak! Thanks for your response.
>
> To clarify what I'm doing: my source page contains a number of tags like
> this:
>
> <input value="a7684624-aa9d-4bdd-be3c-97e8d67485d4"
> name="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1" type="radio" id="[snip]"
> CssClass="rdbtn" GroupName="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1"
> checked="checked" />
>
> I am grabbing them with this regexp:
>
> <input
>
> value="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12})"
>
> name="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12}_1)".*?checked="checked"
>
> and then using a ForEach controller and a beanshell sampler to build the
> following string contained in a JMeter variable:
>
>
> d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&
> [etc etc]
>
> This string contains the = and & signs you would expect to see in a POST
> body. But when JMeter sends this, it URI encodes those characters, so it
> ends up sending:
>
>
> a602b71a-95ab-4046-8b24-8454a6d8a295_1%3Dc8635002-86a7-4841-9d8d-68bd375b1236%26b212fb47-6261-4f74-b8bc-8c7b331ed21a_1%3D4bba8a26-5542-43ef-b8e3-f57a0e95d7b7%26a3cdbda4-ea65-4a0a-95b0-99b94fb782de_1
> [etc etc]
>
> Note that & has become %26 and = has become %3D. Then, of course, the web
> service I'm calling doesn't seen all those name=value pairs, it just sees a
> single parameter. This happens when the "encode?" tickbox on the
> HTTPRequest
> is ticked _or_ unticked.
>
> On Mon, Nov 9, 2009 at 5:14 PM, Deepak Shetty <shettyd@...> wrote:
>
> > Hi
> > a. When you say URL encode do you mean the %nn for non ascii characters
> or
> > the & encoded as & (because these are HTML encoded to escape & and
> need
> > to be dealt with differently).
> > What does the source actually have? If the source html on which you are
> > running your regex to extract data , is already encoded , then checking
> or
> > unchecking the checkbox will appear to have to no effect (it might get
> > double encoded). can you add Debug samplers to check whether the data you
> > are extracting out is correct or already encoded?
> > b. Checking or Unchecking the encode value does work, you can try it
> > standalone with a hardcoded string which has special characters like = or
> +
> >
> > regards
> > deepak
> >
> >
> > On Mon, Nov 9, 2009 at 6:51 AM, Richard Gaywood <
> richardgaywood@...
> > >wrote:
> >
> > > Hi list! Encountered a problem with JMeter (v2.3.4) that I cannot find
> a
> > > workaround for. Hoping someone has a suggestion I've overlooked.
> > >
> > > I have a complicated HTTP POST request (70+ parameters, with a number
> of
> > > variable substitutions). I've coded it up but encountered a problem
> with
> > > eleven parameters that were just GUID name/value pairings. Some work
> with
> > a
> > > regular expression extractor, a Beanshell sampler, and a ForEach
> > controller
> > > has constructed these into a single JMeter variable with the usual
> > > "name=value&name=value&name=value&" (etc) structure.
> > >
> > > My problem is, JMeter is insisting in URL encoding the JMeter variable
> > > contents when I put it in the "send parameters with the request"
> section,
> > > regardless of how I tick or untick the "encode?" column. I found this
> old
> > > post by sebb:
> > >
> > > On Mon, Oct 8, 2007 at 7:40 PM, sebb <sebbaz@...> wrote:
> > >
> > >> OK, in that case I think there is a work-round.
> > >>
> > >> If you use parameters with values but *no names*, then HttpClient (and
> > >> Java http) will include the values in the POST body as is with no
> > >> encoding or equals signs.
> > >>
> > >> (This does not appear to be documented anywhere ... oops!)
> > >>
> > >
> > > But this only seems to work when I only have one single line in the
> > request
> > > parameters config. As soon as I mix the workaround with normally
> encoded
> > > parameters, JMeter stops working. See my screenshot -- where I set two
> > > parameters; the first a JMeter variable containing the string
> > > "name=value&spam=eggs" and the other a normal parameter with name "ham"
> > and
> > > value "green". When I hit send, the POST parameters look like:
> > >         POST data:
> > >         ham=green
> > > ...with no mention of the other two parameters.
> > >
> > > So... is there a workaround for this? Or do I need to manually URL
> encode
> > > my 60-odd parameters and put them all in a single Value box of my
> > > HTTPClient?
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-user-unsubscribe@...
> > > For additional commands, e-mail: jmeter-user-help@...
> > >
> >
>

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Deepak Shetty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
Im not sure how you are doing this, it works fine for me
ThreadGroup
+HTTPRequest(POST)
++<NO NAME> ,
a=b&d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&
, Uncheck Encode parameters.

Value in View Result Tree

POST data:
a=b&d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&

regards
deepak


On Mon, Nov 9, 2009 at 9:49 AM, Richard Gaywood <richardgaywood@...>wrote:

> Hi Deepak! Thanks for your response.
>
> To clarify what I'm doing: my source page contains a number of tags like
> this:
>
> <input value="a7684624-aa9d-4bdd-be3c-97e8d67485d4"
> name="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1" type="radio" id="[snip]"
> CssClass="rdbtn" GroupName="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1"
> checked="checked" />
>
> I am grabbing them with this regexp:
>
> <input
>
> value="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12})"
>
> name="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12}_1)".*?checked="checked"
>
> and then using a ForEach controller and a beanshell sampler to build the
> following string contained in a JMeter variable:
>
>
> d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&
> [etc etc]
>
> This string contains the = and & signs you would expect to see in a POST
> body. But when JMeter sends this, it URI encodes those characters, so it
> ends up sending:
>
>
> a602b71a-95ab-4046-8b24-8454a6d8a295_1%3Dc8635002-86a7-4841-9d8d-68bd375b1236%26b212fb47-6261-4f74-b8bc-8c7b331ed21a_1%3D4bba8a26-5542-43ef-b8e3-f57a0e95d7b7%26a3cdbda4-ea65-4a0a-95b0-99b94fb782de_1
> [etc etc]
>
> Note that & has become %26 and = has become %3D. Then, of course, the web
> service I'm calling doesn't seen all those name=value pairs, it just sees a
> single parameter. This happens when the "encode?" tickbox on the
> HTTPRequest
> is ticked _or_ unticked.
>
> On Mon, Nov 9, 2009 at 5:14 PM, Deepak Shetty <shettyd@...> wrote:
>
> > Hi
> > a. When you say URL encode do you mean the %nn for non ascii characters
> or
> > the & encoded as & (because these are HTML encoded to escape & and
> need
> > to be dealt with differently).
> > What does the source actually have? If the source html on which you are
> > running your regex to extract data , is already encoded , then checking
> or
> > unchecking the checkbox will appear to have to no effect (it might get
> > double encoded). can you add Debug samplers to check whether the data you
> > are extracting out is correct or already encoded?
> > b. Checking or Unchecking the encode value does work, you can try it
> > standalone with a hardcoded string which has special characters like = or
> +
> >
> > regards
> > deepak
> >
> >
> > On Mon, Nov 9, 2009 at 6:51 AM, Richard Gaywood <
> richardgaywood@...
> > >wrote:
> >
> > > Hi list! Encountered a problem with JMeter (v2.3.4) that I cannot find
> a
> > > workaround for. Hoping someone has a suggestion I've overlooked.
> > >
> > > I have a complicated HTTP POST request (70+ parameters, with a number
> of
> > > variable substitutions). I've coded it up but encountered a problem
> with
> > > eleven parameters that were just GUID name/value pairings. Some work
> with
> > a
> > > regular expression extractor, a Beanshell sampler, and a ForEach
> > controller
> > > has constructed these into a single JMeter variable with the usual
> > > "name=value&name=value&name=value&" (etc) structure.
> > >
> > > My problem is, JMeter is insisting in URL encoding the JMeter variable
> > > contents when I put it in the "send parameters with the request"
> section,
> > > regardless of how I tick or untick the "encode?" column. I found this
> old
> > > post by sebb:
> > >
> > > On Mon, Oct 8, 2007 at 7:40 PM, sebb <sebbaz@...> wrote:
> > >
> > >> OK, in that case I think there is a work-round.
> > >>
> > >> If you use parameters with values but *no names*, then HttpClient (and
> > >> Java http) will include the values in the POST body as is with no
> > >> encoding or equals signs.
> > >>
> > >> (This does not appear to be documented anywhere ... oops!)
> > >>
> > >
> > > But this only seems to work when I only have one single line in the
> > request
> > > parameters config. As soon as I mix the workaround with normally
> encoded
> > > parameters, JMeter stops working. See my screenshot -- where I set two
> > > parameters; the first a JMeter variable containing the string
> > > "name=value&spam=eggs" and the other a normal parameter with name "ham"
> > and
> > > value "green". When I hit send, the POST parameters look like:
> > >         POST data:
> > >         ham=green
> > > ...with no mention of the other two parameters.
> > >
> > > So... is there a workaround for this? Or do I need to manually URL
> encode
> > > my 60-odd parameters and put them all in a single Value box of my
> > > HTTPClient?
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-user-unsubscribe@...
> > > For additional commands, e-mail: jmeter-user-help@...
> > >
> >
>

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Richard Gaywood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

HI Deepak. Thanks for helping me with this problem. I've attached a minimal test JMX; what am I doing wrong?



On Mon, Nov 9, 2009 at 7:04 PM, Deepak Shetty <shettyd@...> wrote:
Hi
Im not sure how you are doing this, it works fine for me
ThreadGroup
+HTTPRequest(POST)
++<NO NAME> ,
a=b&d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&
, Uncheck Encode parameters.

Value in View Result Tree

POST data:
a=b&d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&

regards
deepak


On Mon, Nov 9, 2009 at 9:49 AM, Richard Gaywood <richardgaywood@...>wrote:

> Hi Deepak! Thanks for your response.
>
> To clarify what I'm doing: my source page contains a number of tags like
> this:
>
> <input value="a7684624-aa9d-4bdd-be3c-97e8d67485d4"
> name="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1" type="radio" id="[snip]"
> CssClass="rdbtn" GroupName="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1"
> checked="checked" />
>
> I am grabbing them with this regexp:
>
> <input
>
> value="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12})"
>
> name="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12}_1)".*?checked="checked"
>
> and then using a ForEach controller and a beanshell sampler to build the
> following string contained in a JMeter variable:
>
>
> d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&
> [etc etc]
>
> This string contains the = and & signs you would expect to see in a POST
> body. But when JMeter sends this, it URI encodes those characters, so it
> ends up sending:
>
>
> a602b71a-95ab-4046-8b24-8454a6d8a295_1%3Dc8635002-86a7-4841-9d8d-68bd375b1236%26b212fb47-6261-4f74-b8bc-8c7b331ed21a_1%3D4bba8a26-5542-43ef-b8e3-f57a0e95d7b7%26a3cdbda4-ea65-4a0a-95b0-99b94fb782de_1
> [etc etc]
>
> Note that & has become %26 and = has become %3D. Then, of course, the web
> service I'm calling doesn't seen all those name=value pairs, it just sees a
> single parameter. This happens when the "encode?" tickbox on the
> HTTPRequest
> is ticked _or_ unticked.
>
> On Mon, Nov 9, 2009 at 5:14 PM, Deepak Shetty <shettyd@...> wrote:
>
> > Hi
> > a. When you say URL encode do you mean the %nn for non ascii characters
> or
> > the & encoded as &amp; (because these are HTML encoded to escape & and
> need
> > to be dealt with differently).
> > What does the source actually have? If the source html on which you are
> > running your regex to extract data , is already encoded , then checking
> or
> > unchecking the checkbox will appear to have to no effect (it might get
> > double encoded). can you add Debug samplers to check whether the data you
> > are extracting out is correct or already encoded?
> > b. Checking or Unchecking the encode value does work, you can try it
> > standalone with a hardcoded string which has special characters like = or
> +
> >
> > regards
> > deepak
> >
> >
> > On Mon, Nov 9, 2009 at 6:51 AM, Richard Gaywood <
> richardgaywood@...
> > >wrote:
> >
> > > Hi list! Encountered a problem with JMeter (v2.3.4) that I cannot find
> a
> > > workaround for. Hoping someone has a suggestion I've overlooked.
> > >
> > > I have a complicated HTTP POST request (70+ parameters, with a number
> of
> > > variable substitutions). I've coded it up but encountered a problem
> with
> > > eleven parameters that were just GUID name/value pairings. Some work
> with
> > a
> > > regular expression extractor, a Beanshell sampler, and a ForEach
> > controller
> > > has constructed these into a single JMeter variable with the usual
> > > "name=value&name=value&name=value&" (etc) structure.
> > >
> > > My problem is, JMeter is insisting in URL encoding the JMeter variable
> > > contents when I put it in the "send parameters with the request"
> section,
> > > regardless of how I tick or untick the "encode?" column. I found this
> old
> > > post by sebb:
> > >
> > > On Mon, Oct 8, 2007 at 7:40 PM, sebb <sebbaz@...> wrote:
> > >
> > >> OK, in that case I think there is a work-round.
> > >>
> > >> If you use parameters with values but *no names*, then HttpClient (and
> > >> Java http) will include the values in the POST body as is with no
> > >> encoding or equals signs.
> > >>
> > >> (This does not appear to be documented anywhere ... oops!)
> > >>
> > >
> > > But this only seems to work when I only have one single line in the
> > request
> > > parameters config. As soon as I mix the workaround with normally
> encoded
> > > parameters, JMeter stops working. See my screenshot -- where I set two
> > > parameters; the first a JMeter variable containing the string
> > > "name=value&spam=eggs" and the other a normal parameter with name "ham"
> > and
> > > value "green". When I hit send, the POST parameters look like:
> > >         POST data:
> > >         ham=green
> > > ...with no mention of the other two parameters.
> > >
> > > So... is there a workaround for this? Or do I need to manually URL
> encode
> > > my 60-odd parameters and put them all in a single Value box of my
> > > HTTPClient?
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-user-unsubscribe@...
> > > For additional commands, e-mail: jmeter-user-help@...
> > >
> >
>



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@...
For additional commands, e-mail: jmeter-user-help@...

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Deepak Shetty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

attachments dont go through to the list , youll either have to upload it
somewhere or describe the test
regards
deepak

On Tue, Nov 10, 2009 at 3:08 AM, Richard Gaywood
<richardgaywood@...>wrote:

> HI Deepak. Thanks for helping me with this problem. I've attached a minimal
> test JMX; what am I doing wrong?
>
>
>
>
> On Mon, Nov 9, 2009 at 7:04 PM, Deepak Shetty <shettyd@...> wrote:
>
>> Hi
>> Im not sure how you are doing this, it works fine for me
>> ThreadGroup
>> +HTTPRequest(POST)
>> ++<NO NAME> ,
>>
>> a=b&d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&
>> , Uncheck Encode parameters.
>>
>> Value in View Result Tree
>>
>> POST data:
>>
>> a=b&d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&
>>
>> regards
>> deepak
>>
>>
>> On Mon, Nov 9, 2009 at 9:49 AM, Richard Gaywood <richardgaywood@...
>> >wrote:
>>
>> > Hi Deepak! Thanks for your response.
>> >
>> > To clarify what I'm doing: my source page contains a number of tags like
>> > this:
>> >
>> > <input value="a7684624-aa9d-4bdd-be3c-97e8d67485d4"
>> > name="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1" type="radio" id="[snip]"
>> > CssClass="rdbtn" GroupName="0eeaaef9-d725-4608-bcbb-6e4e55af41d3_1"
>> > checked="checked" />
>> >
>> > I am grabbing them with this regexp:
>> >
>> > <input
>> >
>> >
>> value="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12})"
>> >
>> >
>> name="([a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12}_1)".*?checked="checked"
>> >
>> > and then using a ForEach controller and a beanshell sampler to build the
>> > following string contained in a JMeter variable:
>> >
>> >
>> >
>> d49c8919-36d2-4825-b739-ff10752f3ede_1=efa5f43d-395e-4c92-9579-bc4215b0773c&f855d8c6-9cd8-419e-836e-59ad55565dab_1=1c40bc35-86f8-4e30-aa5c-2efb7284c4e2&bd5b9945-3c29-4c81-b890-e782f2385471_1=dd78cbb0-2d00-48af-aa77-6a3b1af8bd15&
>> > [etc etc]
>> >
>> > This string contains the = and & signs you would expect to see in a POST
>> > body. But when JMeter sends this, it URI encodes those characters, so it
>> > ends up sending:
>> >
>> >
>> >
>> a602b71a-95ab-4046-8b24-8454a6d8a295_1%3Dc8635002-86a7-4841-9d8d-68bd375b1236%26b212fb47-6261-4f74-b8bc-8c7b331ed21a_1%3D4bba8a26-5542-43ef-b8e3-f57a0e95d7b7%26a3cdbda4-ea65-4a0a-95b0-99b94fb782de_1
>> > [etc etc]
>> >
>> > Note that & has become %26 and = has become %3D. Then, of course, the
>> web
>> > service I'm calling doesn't seen all those name=value pairs, it just
>> sees a
>> > single parameter. This happens when the "encode?" tickbox on the
>> > HTTPRequest
>> > is ticked _or_ unticked.
>> >
>> > On Mon, Nov 9, 2009 at 5:14 PM, Deepak Shetty <shettyd@...>
>> wrote:
>> >
>> > > Hi
>> > > a. When you say URL encode do you mean the %nn for non ascii
>> characters
>> > or
>> > > the & encoded as & (because these are HTML encoded to escape & and
>> > need
>> > > to be dealt with differently).
>> > > What does the source actually have? If the source html on which you
>> are
>> > > running your regex to extract data , is already encoded , then
>> checking
>> > or
>> > > unchecking the checkbox will appear to have to no effect (it might get
>> > > double encoded). can you add Debug samplers to check whether the data
>> you
>> > > are extracting out is correct or already encoded?
>> > > b. Checking or Unchecking the encode value does work, you can try it
>> > > standalone with a hardcoded string which has special characters like =
>> or
>> > +
>> > >
>> > > regards
>> > > deepak
>> > >
>> > >
>> > > On Mon, Nov 9, 2009 at 6:51 AM, Richard Gaywood <
>> > richardgaywood@...
>> > > >wrote:
>> > >
>> > > > Hi list! Encountered a problem with JMeter (v2.3.4) that I cannot
>> find
>> > a
>> > > > workaround for. Hoping someone has a suggestion I've overlooked.
>> > > >
>> > > > I have a complicated HTTP POST request (70+ parameters, with a
>> number
>> > of
>> > > > variable substitutions). I've coded it up but encountered a problem
>> > with
>> > > > eleven parameters that were just GUID name/value pairings. Some work
>> > with
>> > > a
>> > > > regular expression extractor, a Beanshell sampler, and a ForEach
>> > > controller
>> > > > has constructed these into a single JMeter variable with the usual
>> > > > "name=value&name=value&name=value&" (etc) structure.
>> > > >
>> > > > My problem is, JMeter is insisting in URL encoding the JMeter
>> variable
>> > > > contents when I put it in the "send parameters with the request"
>> > section,
>> > > > regardless of how I tick or untick the "encode?" column. I found
>> this
>> > old
>> > > > post by sebb:
>> > > >
>> > > > On Mon, Oct 8, 2007 at 7:40 PM, sebb <sebbaz@...> wrote:
>> > > >
>> > > >> OK, in that case I think there is a work-round.
>> > > >>
>> > > >> If you use parameters with values but *no names*, then HttpClient
>> (and
>> > > >> Java http) will include the values in the POST body as is with no
>> > > >> encoding or equals signs.
>> > > >>
>> > > >> (This does not appear to be documented anywhere ... oops!)
>> > > >>
>> > > >
>> > > > But this only seems to work when I only have one single line in the
>> > > request
>> > > > parameters config. As soon as I mix the workaround with normally
>> > encoded
>> > > > parameters, JMeter stops working. See my screenshot -- where I set
>> two
>> > > > parameters; the first a JMeter variable containing the string
>> > > > "name=value&spam=eggs" and the other a normal parameter with name
>> "ham"
>> > > and
>> > > > value "green". When I hit send, the POST parameters look like:
>> > > >         POST data:
>> > > >         ham=green
>> > > > ...with no mention of the other two parameters.
>> > > >
>> > > > So... is there a workaround for this? Or do I need to manually URL
>> > encode
>> > > > my 60-odd parameters and put them all in a single Value box of my
>> > > > HTTPClient?
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> ---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail: jmeter-user-unsubscribe@...
>> > > > For additional commands, e-mail:
>> jmeter-user-help@...
>> > > >
>> > >
>> >
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@...
> For additional commands, e-mail: jmeter-user-help@...
>

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Richard Gaywood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Nov 10, 2009 at 4:48 PM, Deepak Shetty <shettyd@...> wrote:

> attachments dont go through to the list , youll either have to upload it
> somewhere or describe the test
>

Aha! No problem. The test is here:
http://stuff.fscked.co.uk/foo.jmx

My Apache seems to want to serve that as plain text, so you might prefer:
http://stuff.fscked.co.uk/foo.zip
which has the JMX file in.

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Deepak Shetty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
attempt 4 works for me (JMeter 2.3.4, JDK 1.5)

POST http://cgi.www.emccsoft.com/cgi-bin/www.emccsoft.com/post.pl

POST data:
foo=bar&spam=eggs

[no cookies]

Request Headers:
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 17
User-Agent: Jakarta Commons-HttpClient/3.1
Host: cgi.www.emccsoft.com

I dont think you can mix the parameters with no names with parameters with
names (either all should have or none should have).
As before i believe you can get you stuff to work easier with BSH pre
processor.

regards
deepak


On Wed, Nov 11, 2009 at 1:48 AM, Richard Gaywood
<richardgaywood@...>wrote:

> On Tue, Nov 10, 2009 at 4:48 PM, Deepak Shetty <shettyd@...> wrote:
>
> > attachments dont go through to the list , youll either have to upload it
> > somewhere or describe the test
> >
>
> Aha! No problem. The test is here:
> http://stuff.fscked.co.uk/foo.jmx
>
> My Apache seems to want to serve that as plain text, so you might prefer:
> http://stuff.fscked.co.uk/foo.zip
> which has the JMX file in.
>

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Richard Gaywood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 11, 2009 at 6:29 PM, Deepak Shetty <shettyd@...> wrote:

> I dont think you can mix the parameters with no names with parameters with
> names (either all should have or none should have).
>

Yes, I think you are correct.


> As before i believe you can get you stuff to work easier with BSH pre
> processor


I've had a go at that. http://stuff.fscked.co.uk/foo2.zip

Both attempt7 and attempt8 encode the contents of ${foo}, even though one
invokes addArgument() and the other addEncodedArgument(). Attempt9 tries to
use only a no-name parameter in the sampler and add other parameters using a
pre-processor, but that doesn't work either, the other parameters are
ignored.

I'm really stuck here :(

Re: Using URL Encoded values in a JMeter variable in a HTTP POST

by Deepak Shetty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
what I mean in the Beanshell preprocessor is that there is no need for you
to form the String (I believe you said you were ).
You can loop through your extracted values and use addArgument in a loop.

Alternately if your extracted value already has the  concatenated value you
want to send, you can parse the String and use addArgument again(using split
on & and then for each value split on =)


regards
deepak


On Thu, Nov 12, 2009 at 9:09 AM, Richard Gaywood
<richardgaywood@...>wrote:

> On Wed, Nov 11, 2009 at 6:29 PM, Deepak Shetty <shettyd@...> wrote:
>
> > I dont think you can mix the parameters with no names with parameters
> with
> > names (either all should have or none should have).
> >
>
> Yes, I think you are correct.
>
>
> > As before i believe you can get you stuff to work easier with BSH pre
> > processor
>
>
> I've had a go at that. http://stuff.fscked.co.uk/foo2.zip
>
> Both attempt7 and attempt8 encode the contents of ${foo}, even though one
> invokes addArgument() and the other addEncodedArgument(). Attempt9 tries to
> use only a no-name parameter in the sampler and add other parameters using
> a
> pre-processor, but that doesn't work either, the other parameters are
> ignored.
>
> I'm really stuck here :(
>