API sendRequest or requestAndVerify is not working?

I’ve seen this reported before and there was no response from Katalon development… and the temp solution provided by other users does not work.

I am unable to send API request due to sendRequest is not being recognized…but sometimes the request does go thru. This is strange.

This is blocking us from implementing API tests properly. This keyword was working awhile ago. Am I missing something here?

if i get rid of the (findTestObject … then sendRequest is no longer underlined… i don’t know if that’s how it is now… but this does not work.

image

If you change your code as follows, the underline will disappear

ResponseObject response = WS.sendRequest((RequestObject)findTestObject('API Web service/POST resetFS folder' , [('de_url'): '......']))

Rational:

  1. WS.sendRequest(arg0) requires an instance of com.kms.katalon.core.testobject.RequestObject as the argument
  2. findTestObject(String) method returns an instance of com.kms.katalon.core.testobject.TestObject.
  3. therefore the Test Case editor detected a type mismatch, hence warned it by underlining.
  4. RequestObject class is a subtype of TestObject.
  5. So you can cheat the Test Case editor by casting a TestObject returned by findTestObject(...) to a RequestObject.

Please note, this underline is not very significant. It is just a warning emitted by the editor. It is possibly not the reason why you test case fails. Even if the underline is erased, you test case may still fail due to some reason which is not yet looked at.

In my humble opinion, it would be better if I could write the code as follows:

import static com.kms.katalon.core.testobject.ObjectRepository.findRequestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.ResponseObject

ResponseObject response = WS.sendRequest(findRequestObject('API Web service/POST resetFS folder', [('dev_url'): '....']))

I mean, we need the ObjectRepository to implement findRequestObject method which returns an instance of RequestObject. With it, no type-casting will be required.

Unfortunately findRequestObject method is not provided actually.

c/c @duyluong

1 Like

This tells nothing to others.
Please provide more information: logs, screenshot, your test case script, test object definition, the target URL if it is public etc. See the following guidance.

This worked. I figured it out before but forgot to update the thread. But credits to you nonetheless.