API testing from test complete

Originally posted by yuva on March 01, 2025

How to automate the API testing with test complete tool.

Originally posted by Hassan_Ballan on March 02, 2025

You can follow the following reference TestComplete REST APIs | TestComplete Documentation

Originally posted by rraghvani on March 03, 2025

Also, see https://support.smartbear.com/testcomplete/docs/working-with/integration/ready-api/index.html

Originally posted by MW_Didata on March 03, 2025

For testing APIs I suggest using dedicated software for that.

We switched over to Bruno for all api tests,

It’s very easy to use and open source software.

However if you just need to call 1 or 2 endpoints then that is possible from within TestComplete.

Originally posted by scot1967 on March 03, 2025

Here is an example function written in JavaScript using the TestComplete aqHttp Object for direct testing. It’s very basic but you should be able to build it out from here.

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqhttp/index.html

Thanks to catalin_ochisor

Hmm… your statement above not correct: both SoapUI and ReadyAPI integrate with TestComplete

If you have the Web Module, SoapUI is free and supported by SmartBear. ReadyAPI is Smartbear’s paid option and is better as far as use and capability. Otherwise you will need to use a shell call to the TestRunner and parse StdOut.

https://support.smartbear.com/testcomplete/docs/working-with/integration/ready-api/requirements.html

https://support.smartbear.com/testcomplete/docs/working-with/integration/ready-api/index.html

function sendGetRequest() 
{
  let resourcePath = "https://api.anycompany.com/InventoryManagement/ReceivingGridSelect"
  let resourceQuery = "?PurchasingDocument=21967";
  let url = resourcePath + resourceQuery;
  try 
  {
    // Send GET request
    let response = aqHttp.CreateRequest("GET", url, false).Send();
    // Check for successful response
    if (response.StatusCode === 200) 
    {
      // Parse JSON response
      let allData = JSON.parse(response.Text);
      Log.Message("Total records received: " + allData.length);
      // Process each record
      allData.forEach((record, index) => {
        Log.Message("Record " + (index + 1) + ": " + JSON.stringify(record));
      });
    } 
    else 
    {
      Log.Error("Failed to fetch data. Status code: " + response.StatusCode);
    }
  } 
  catch (error) 
  {
    Log.Error("Error during request or data processing: " + error.message);
  }
}

Example data returned from this function.

Originally posted by caitlinrich on March 03, 2025

While TestComplete does have some limited capability to test APIs, the best solution is to use Smartbear’s dedicated API testing tool ReadyAPI. ReadyAPI is a low-code API testing platform, and TestComplete can run functional and security tests created with ReadyAPI.

More information about the TestComplete and ReadyAPI integration can be found in the TestComplete documentation.

Originally posted by rraghvani on March 03, 2025

The aqHttp object is based on IWinHttpRequest (from WinHTTP) which is considered to be old and outdated for most modern Windows applications. It was originally designed for low-level HTTP communication in Windows.

Originally posted by catalin_ochisor on March 03, 2025

Hmm… your statement above not correct: both SoapUI and ReadyAPI integrate with TestComplete

https://support.smartbear.com/testcomplete/docs/working-with/integration/ready-api/index.html

Originally posted by scot1967 on March 03, 2025

Ah, I see. This will return the assertion results then? I have not tried this. In my code I am pulling the JSON data from the API call to use as data for further testing and verification. Can this be done here as well?

Originally posted by scot1967 on March 03, 2025

I don’t have the web module. All of my code has been based on what I have learned mostly with SoapUI, JavaScript and what can be done without additional licensing. I will do some research here and learn about the possibilities. Thanks!

Originally posted by scot1967 on March 03, 2025

So, it looks like the short answer is YES you can. It looks like this integration provides a nice way to access the TestRunner and provide better logging to TestComplete. :+1:

Parsing the JSON would likely be unchanged as it would likely still need a Groovy script in SoapUI or ReadyAPI to process the JSON to a File for TestComplete or pull directly from StdOut.

Very nice. :smiling_face_with_sunglasses: