I am going to send a POST request and verify the value of an element from response.
1. I had created a simply POST request to a random API interface from URL = https://httpbin.org/get
Then I send a request and get the response which looks like
Method Not Allowed
The method is not allowed for the requested URL.
2. I had created a test case and call a request from an embedded method sendRequest
So my whole script of this test case looks like
…
def response = WS.sendRequest(findTestObject(‘API/Test/Test’))
def result = println('shtitest: ’ + response)
3. I run this script and expect that my response would be exactly as at step number 1.
Actually the response looks like
**com.kms.katalon.core.testobject.ResponseObject@366c4480
**Console log:
…
09-17-2018 12:08:16 AM - [END] - End action : Statement - response = com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.sendRequest(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(API/Test/Test))
09-17-2018 12:08:16 AM - [START] - Start action : Statement - result = println("shtitest: " + response)
shtitest: com.kms.katalon.core.testobject.ResponseObject@3b0c9195
09-17-2018 12:08:16 AM - [END] - End action : Statement - result = println("shtitest: " + response)
09-17-2018 12:08:16 AM - [PASSED] - Test Cases/New Test Case
09-17-2018 12:08:16 AM - [END] - End Test Case : Test Cases/New Test Case
Then I decided to verify the response status code using a WS.verifyResponseStatusCode exactly as in a your documentation here
https://docs.katalon.com/display/KD/[WS]+Verify+Response+Status+Code
Please check my test case
def response = WS.sendRequest(findTestObject(‘API/Test/Test’))
not_run: def result = println('shtitest: ’ + response)
**WS.verifyResponseStatusCode(‘response’, 200)
**Here I got an error
09-17-2018 12:17:05 AM - [ERROR] - Test Cases/New Test Case FAILED because (of) (Stack trace: groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.verifyResponseStatusCode() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [response, 200]
Possible solutions: verifyResponseStatusCode(com.kms.katalon.core.testobject.ResponseObject, int), verifyResponseStatusCode(com.kms.katalon.core.testobject.ResponseObject, int, com.kms.katalon.core.model.FailureHandling)
What exactly should I do for running an API request from a test case context?