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.
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.
This is the latest one while some of the methods are depreceated, just wanted to document here for anyone who is struggling like me to get this solution
import com.kms.katalon.core.testobject.impl.HttpFileBodyContent
import com.kms.katalon.core.testobject.impl.HttpFormDataBodyContent
import com.kms.katalon.core.testobject.impl.HttpUrlEncodedBodyContent as HttpUrlEncodeBodyContent
import com.kms.katalon.core.testobject.UrlEncodedBodyParameter as UrlEncodedBodyParameter
//Verify the 200 message is displayed
assert request.getStatusCode() == 200
//Getting the Response body value
def slurper = new JsonSlurper()
def response= slurper.parseText(request.getResponseText())
//Getting the token from the API’s response and passing on to the Global Variable
def Token = response.access_token
GlobalVariable.TOKEN = “Bearer” + " " + Token
println GlobalVariable.TOKEN