QuickTest Pro How to Test a REST Service

Automation Testing Published on:
Code Hacker

In this video, I show a quick example on how to use QuickTest Pro 11 and WinHttp to test a REST service. The QTP web-addin is not needed for this example.

Below is the code used for this example:

Set myRestBody = XMLUtil.CreateXMLFromFile("C:\body.xml") 
restRequest = myRestBody.ToString
url ="http://localhost:24240/HPFlights_REST/FlightOrders/"
contentType ="text/XML"
'1) Create reference to the WinHTTP request com object
 Set oWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1") 
 '2) Open a HTTP connection to a HTTP resource 
 oWinHttp.Open "POST", url, False
 '3) Add a HTTP request headers for endpoint and conent type
 oWinHttp.setRequestHeader "Content-Type", contentType 	oWinHttp.setRequestHeader "SOAPAction", url
'4) Send a HTTP request to the HTTP server with the header and body info
oWinHttp.Send restRequest
'5) Get response
 response = oWinHttp.ResponseText
'6) Close object reference 
Set oWinHttp = Nothing
'7) print the response
print response
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
Code Hacker

Top 17 Accessibility Testing Tools for Automation (2023)

Posted on 03/21/2023

Although automation is not a silver bullet for accessibility testing, here are some ...

Best Python Automation Testing Tools (For 2023)

Posted on 03/19/2023

As a modern tester, I know you would probably say that Java is ...

4 Common Reasons Enterprise Testing Fails (Tips for Success)

Posted on 03/14/2023

With the pressure to create software faster and with higher quality, teams are ...