Introduction to HTTP Requests
You create an instance of %Net.HttpRequestOpens in a new tab to send HTTP requests of various kinds and receive the responses. This object is equivalent to a web browser, and you can use it to make multiple requests. It automatically sends the correct cookies and sets the Referer header as appropriate.
To create an HTTP request, use the following general process:
-
Create an instance of %Net.HttpRequestOpens in a new tab.
-
Set properties of this instance to indicate the web server to communicate with. The basic properties are as follows:
-
Optionally set other properties and call methods of your HTTP request, as described in Specifying Other HTTP Request Properties.
-
Then send an HTTP request, by calling the Get() method or other methods of your instance of %Net.HttpRequestOpens in a new tab, as described in Sending the HTTP Request.
You can make multiple requests from your instance, which will automatically handle cookies and the Referer header.
-
Use the same instance of %Net.HttpRequestOpens in a new tab to send additional HTTP requests if needed. By default, InterSystems IRIS® data platform keeps the TCP/IP socket open so that you can reuse the socket without closing and reopening it.
For additional information, see Managing Socket Reuse.
The following shows a simple example:
set request=##class(%Net.HttpRequest).%New()
set request.Server="tools.ietf.org"
set request.Https=1
set request.SSLConfiguration="TEST"
set status=request.Get("/html/rfc7158")
For information on the Https and SSLConfiguration properties, see Using SSL to Connect, later in this topic. Also, for a more complete version of this example, see Accessing the HTTP Response.