Using variables in web service request object

Hi Guys, I’m facing a problem. I need to create a user doing a POST requisition, but one of the properties cannot be repeated, so I generate a value in my script and i want to replace the value of property in my JSON for the value i had generate in the variable.
Until here, i’ve tried two ways to deal with it:

object = (findTestObject(‘Users/ValidaCriacaoUsuario/CriaUsuarioComSucesso’))

object.findProperty(‘CPF’).setValue(cpf)

object.findProperty(‘CPF’).setActive(true)

when i run, i got this error:
05-29-2018 04:55:56 PM - [ERROR] - Test Cases/Users/ValidaCriacaoUsuario FAILED because (of) java.lang.NullPointerException: Cannot invoke method setValue() on null object

And i don’t know why i got this error, because the object has this propertys in the body.
The second way i tried unsuccessfully, was using a WebUI keyword, and i don’t got any error, but it’s not working too (the value in the property keep the same):

WebUI.modifyObjectProperty(object, ‘CPF’, ‘equals’, cpf, true, FailureHandling.STOP_ON_FAILURE)

Can anyone help me ? I’m new in katalon and don’t know if there is any way to do this or it can be a limitation of the tool once the body gets ‘fixed’ on the object

Thanks!!

Could you try following approach: https://docs.katalon.com//display/KD/Parameterize+a+Web+Service+object?

2 Likes

Thanks!! It helped me a lot