Parameterize UrlEncodedHttpBody in Web Service Object does not work with variables

I have seen Here:
and here:

How to dinamically parametraze your web service objects.
But none of these works with Url Encoded Body parameters… Why Not?

This does not work:

Also, if instead of this I want to do it programatically (which is fine for me) If we look at the class
HttpUrlEncodedBodyContent in the documentation:

There is no method to iterate through the ‘List<UrlEncodedBodyParameter> parameters’… and not even get them. so I can’t get the body parameters of the request, modify them, and create a new HttpUrlEncodedBodyContent to set to the request.

Creating the HttpUrlEncodedBodyContent from scratch every time is far from optimal, I have a template in the Object Repository as a Web Service Request, so it makes sense that I could get that request and modify it.

Any way to do this?

Best Regards,

Hi @ixent.gallego

What version are you using ?

My test script

RequestObject to = findTestObject('Object Repository/New Request', ['variable_name' : 'my value']);
println to.httpBody



where variable_name is specified as a variable with empty default value.

Hello @ThanhTo ,

Using Katalon Studio 7.2.6

I had this:

def request = findTestObject(‘Backend/Auth/GetToken’, [(‘username’) : username, (‘password’) : password]) as RequestObject

Kept getting bad request as a response, but if I replace the values with harcoded ones in the request,
it works fine.

Hmmmm, that’s strange. Logging the request body (with variable replacement) this appears:


which seems as expected. But I get a response as if the credentials weren’t good.

Anyway, removed a previous reply because the issues were not correct and was out of the scope of the main problem.

The approach you showed to replace the variables, and the one I initially tried (which is also the one explained in the links) wasn’t working for some reason. But it is true that Logging the request body it appears correctly.

This seems to be an issue at my side, so I’d consider this resolved.

Thanks for your time,

1 Like