Forum Discussion

pooja_kavitke's avatar
pooja_kavitke
Occasional Contributor
9 years ago

Testcomple with API testing

I came to know that testcomplete is not supporting REST protocol for API/webservice testing.

we can still do it wih msxml2.serverxmlhttp.6.0

So i tried below code in testcomplete giving me error Object expected

 

at line one which object should pass?

or is there any way to test REST based service in tetscomplete.

 

ServerXmlHttp = CreateConnection("MSXML2.ServerXMLHTTP.6.0");
ServerXmlHttp.open ("POST", "http://www.domain.com/page.asp")
ServerXmlHttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded")
ServerXmlHttp.setRequestHeader ("Content-Length",Len(PostData))
ServerXmlHttp.send (PostData)

if (ServerXmlHttp.status = 200 )

{
TextResponse = ServerXmlHttp.responseText
XMLResponse = ServerXmlHttp.responseXML
StreamResponse = ServerXmlHttp.responseStream
}
else
{
log.message(" Handle missing response or other errors here")
}

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    >> ServerXmlHttp = CreateConnection("MSXML2.ServerXMLHTTP.6.0");

     

    Is CreateConnection a function defined elsewhere in your script? If not, I guess it needs to be changed to Sys.OleObject():

    ServerXmlHttp = Sys.OleObject("MSXML2.ServerXMLHTTP.6.0");