Forum Discussion
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.
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 01
I am unable to figure out how to fit this in TestComplete/JS