Forum Discussion
10 Replies
- scot1967
Champion Level 1
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
Example data returned from this function.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); } }
- catalin_ochisorOccasional Contributor
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
- scot1967
Champion Level 1
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?
- rraghvani
Champion Level 3
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.
- Hassan_Ballan
Champion Level 1
You can follow the following reference TestComplete REST APIs | TestComplete Documentation
- MW_DidataRegular Contributor
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.
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.