SQL Server
SQL Server
HTTPS GET - Download HTML or any Text Content to a String
See more HTTP Examples
The QuickGetStr method is the simplest way to retrieve a text resource from a web server using an HTTP GET request. The text resource can be HTML, XML, JSON, text, or anything other type of file composed of readable text.
Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Send the HTTP GET and return the content in a string.
DECLARE @str nvarchar(4000)
EXEC sp_OAMethod @http, 'QuickGetStr', @str OUT, 'https://www.chilkatsoft.com/helloWorld.json'
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
RETURN
END
PRINT @str
EXEC sp_OAMethod @http, 'QuickGetStr', @str OUT, 'https://www.chilkatsoft.com/helloWorld.txt'
PRINT @str
EXEC sp_OAMethod @http, 'QuickGetStr', @str OUT, 'https://www.chilkatsoft.com/helloWorld.xml'
PRINT @str
EXEC @hr = sp_OADestroy @http
END
GO