Need help with Web Services Builder

I’m sure I’m doing something wrong but I just don’t know what. I am getting the error below when running my test case. Any help is much appreciated!

05-23-2018 04:40:28 PM - [ERROR] - Test Cases/Test Area FAILED because (of) groovy.lang.MissingMethodException: No signature of method: com.kms.katalon.core.testobject.RestRequestObjectBuilder.withTextBodyContent() is applicable for argument types: (java.util.ArrayList) values: [[com.kms.katalon.core.testobject.impl.HttpTextBodyContent@5733f295]]
Possible solutions: withTextBodyContent(java.lang.String), withTextBodyContent(java.lang.String, java.lang.String), withFileBodyContent(java.lang.String)

**My script:
**

String param = WebUI.callTestCase(findTestCase(‘API/Get Auth Key’), [:], FailureHandling.STOP_ON_FAILURE)

String tripIdentifier = WebUI.callTestCase(findTestCase(‘API/Get Trip Id API’), [:], FailureHandling.STOP_ON_FAILURE)

String requestBody = '{“tripId”: ’ + tripIdentifier + ', “name”: “QA Route”, “description”: “API Test Route from Katalon”}

def builder = new RestRequestObjectBuilder()
def requestObject = builder
.withRestRequestMethod(“POST”)
.withRestUrl(“https://myurl/api/example”)
.withHttpHeaders([
new TestObjectProperty(“Content-Type”,ConditionType.EQUALS,“appplication/json”),
new TestObjectProperty(“Authorization”,ConditionType.EQUALS,'Bearer ’ + param)
])
.withTextBodyContent([
new HttpTextBodyContent(requestBody)
])
.build()

responseRoute = WS.sendRequest(requestObject)

Actually figured this out. Used:

withTextBodyContent(requestBody)

versus new HttpTextBodyContent(requestBody)

…then realized a typo in the content-type.

1 Like