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

Must See TestResults.io Product Review

Posted on 11/21/2022

In this post, we'll look at TestResults.io for a product review. When creating ...

Unlocking end-to-end testing for all with mabl

Posted on 09/27/2022

A recent *study showed that 75% of organizations use a combination of manual ...

AI Powered API Testing (Meet Loadmill)

Posted on 09/21/2022

I just learned of a great tool (Loadmill) to help automated API test ...