Automation Testing

QuickTest Pro How to Test a REST Service

By Test Guild
  • Share:
Join the Guild for FREE
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"}

What is Synthetic Monitoring? (2024 Guide)

Posted on 04/18/2024

I've found over the years many testers are unsure about what is synthetic ...

SafeTest: Next Generation Testing Framework from Netflix

Posted on 03/26/2024

When you think of Netflix the last thing you probably think about is ...

Top Free Automation Tools for Testing Desktop Applications (2024)

Posted on 03/24/2024

While many testers only focus on browser automation there is still a need ...

Discover Why Service Virtualization is a Game-Changer:  Register Now!