Parameterization removes escape character from JSON POST request

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Parameterization removes escape character from JSON POST request

Arup Biswas
Hi,

Need help in below problem..

JMeter script recording capture JSON post request with three escape character(\) and rerun as it is without parameterization it works fine. But if we use any Variable "${xyz}" anywhere in the request body and run in JMeter, all the three slashes(\) becomes two slashes(\) while passing the request to application. Then the request failed as "BAD Request" as application doesn't accept request with two slashes.
I have already tried "FileToString" method but no success.
"Draft":{
"id": 123654656,
"draftdata":{\\\"accCat\\\":\\\"207\\\",\\\"accNumber\\\":\\\"656565
\\\",\\\"id\\\":${Var_ID},...}
}

"Draft":{
"id": 123654656,
"draftdata":{\\\"accCat\\\":\\\"207\\\",\\\"accNumber\\\":\\\"656565
\\\",\\\"id\\\":9876,...}
}

When i pass request with variable the request becomes like below and can be seen in results tree as request body
"Draft":{
"id": 123654656,
"draftdata":{\\"accCat\\":\\"207\\",\\"accNumber\\":\\"656565
\\",\\"id\\":${Var_ID},...}

But without parameterization variable it works perfectly as request goes with three slashes(\).

============================================================================================================================

Disclaimer:  This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html> externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html> internally within TechMahindra.

============================================================================================================================
Reply | Threaded
Open this post in threaded view
|

Re: Parameterization removes escape character from JSON POST request

Felix Schumacher

Am 27.03.19 um 07:32 schrieb Arup Biswas:

> Hi,
>
> Need help in below problem..
>
> JMeter script recording capture JSON post request with three escape character(\) and rerun as it is without parameterization it works fine. But if we use any Variable "${xyz}" anywhere in the request body and run in JMeter, all the three slashes(\) becomes two slashes(\) while passing the request to application. Then the request failed as "BAD Request" as application doesn't accept request with two slashes.
> I have already tried "FileToString" method but no success.
> "Draft":{
> "id": 123654656,
> "draftdata":{\\\"accCat\\\":\\\"207\\\",\\\"accNumber\\\":\\\"656565
> \\\",\\\"id\\\":${Var_ID},...}
> }
>
> "Draft":{
> "id": 123654656,
> "draftdata":{\\\"accCat\\\":\\\"207\\\",\\\"accNumber\\\":\\\"656565
> \\\",\\\"id\\\":9876,...}
> }
>
> When i pass request with variable the request becomes like below and can be seen in results tree as request body
> "Draft":{
> "id": 123654656,
> "draftdata":{\\"accCat\\":\\"207\\",\\"accNumber\\":\\"656565
> \\",\\"id\\":${Var_ID},...}
>
> But without parameterization variable it works perfectly as request goes with three slashes(\).
I think you have the same problem as

https://bz.apache.org/bugzilla/show_bug.cgi?id=63255

I think this is a problem, that we should look at, but at the same time it is probably a behaviour, that is present since many versions and therefore changing it, might affect many users. Such a change has to be considered carefully.

By the way, if you want to give examples -- which I very much like -- you should try to simplify them as much as possible.

Regards,
  Felix

>
> ============================================================================================================================
>
> Disclaimer:  This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at http://www.techmahindra.com/Disclaimer.html <http://www.techmahindra.com/Disclaimer.html> externally http://tim.techmahindra.com/tim/disclaimer.html <http://tim.techmahindra.com/tim/disclaimer.html> internally within TechMahindra.
>
> ============================================================================================================================
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]