Forum Discussion
Hey Chicks,
I am extremely thankful for this. Let me investigate on this. Will update my findings after implementing your work.
Regards,
Obaid Shirwani
Hi Obaid,
SoapUI (http://smartbear.com/product/ready-api/soapui-ng/overview/ or http://www.soapui.org/ depending on your needs) fits better for REST API testing. SoapUI is integrated with TestComplete which means that you can run SoapUI tests from within TestComplete and get consolidated log.
Or, as Chicks already mentioned, you can use coded approach and keep everything within TestComplete.
- Colin_McCrae10 years agoCommunity Hero
Just to back up, you can use - ActiveXObject("MSXML2.XMLHTTP.3.0") - with RESTful API's.
I have a full set of script extensions now built to allow my tests to write their results to TFS using it's new RESTful API.
- obaid_shirwani9 years agoContributor
I have been able to achieve this using pHp and C# but still no luck with TestComplete / JS.
This is how my PHP code looks like:
<?php
$_url = "http://x.y.z.a/xyzqa/index.php/api/BringUsers";
$ch = curl_init($_url);
curl_setopt_array($ch, array(CURLOPT_HTTPHEADER => array('X-REST-USERNAME: admin', 'X-REST-PASSWORD: admin')));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//echo "Calling 'curl_exec':";
$_response = curl_exec($ch);
echo "<br>Closing CURL<br>";
curl_close($ch);
echo "<br><b>Decoding JSON:</b><br>";
$_jsonDecoded = json_decode($_response, true);
print_r($_jsonDecoded);
echo "</br>";This is how my C# code looks like:
//01. Begin: myApp REST API Method 01
static void myAppRESTAPIMethod01()
{
string responseString = "";
string url = @"http://x.y.z.a/xyzqa/index.php/api/BringUsers";
using (WebClient client = new WebClient())
{
client.Headers.Add("X_REST_USERNAME", "admin");
client.Headers.Add("X_REST_PASSWORD", "admin");
//send web request; get web response as XML
try
{
responseString = client.DownloadString(url).ToString();
Console.WriteLine(responseString);
}
catch (Exception ex)
{
Console.WriteLine("ERROR: " + ex.Message);
}
}
}
//01. End: myAppREST API Method 01I am unable to figure out how to fit this in TestComplete/JS
- Yusufm876 years agoContributor
Hi Collin,
I am also trying to update Test Case result in VSTS using REST APIs. I have identified the REST APIs but I am struggling with the Authentication part of it. Could you please help me with that.
Let me know the info you need.
Best Regards,
Yusuf
- AlexKaras6 years agoChampion Level 3
Hi Yusuf,
[Update]
===============
Ah, got it - you like to use VSTS API to do something in VSTS unattended...
In this case you need to read the documentation for VSTS API. And, maybe, talk to your network admins to figure out how it is setup in your company. Most probably it is integrated with your domain, so you will need to make a call to some authentication service to get a token and use the obtaibed token for subsequent API calls.
As I suggested, recording of http traffic that is generated when you do required action from VSTS UI manually may help.
===============
As it has already been mentioned, SoapUI (https://smartbear.com/product/ready-api/soapui/overview/) is much more handy and functional for API testing and is integrated with TestComplete.
If you need to use TestComplete for your API testing, then (unless the tested API is appropriately documented) I would recommend to use some http-recording tool (Fiddler, for example) and record the traffic that is generated when you access this or that API method manually (e.g. using Swagger or a regular browser). Then you need to consider the recorded traffic to understand what parts of it should be parameterized and code it.
Note 1: Depending on your API design, you may be required to call some authentication mathod first to get that authentication token that must be used in subsequent calls. Or provide authentication info (login/password) for every API call.
Note 2: Consider the aqHTTP object that was introduced in TestComplete since the thread was started.
Related Content
Recent Discussions
- 27 days ago
- 5 days ago
- 5 days ago
- 8 days ago