(SQL Server) Example: Http.GetRequestHeader method
Demonstrates the GetRequestHeader method.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
DECLARE @http int
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @hdr1 nvarchar(4000)
SELECT @hdr1 = 'X-CSRF-Token'
DECLARE @hdr2 nvarchar(4000)
SELECT @hdr2 = 'X-Example'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, @hdr1, 'Fetch'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, @hdr2, '123ABC'
EXEC sp_OAMethod @http, 'GetRequestHeader', @sTmp0 OUT, @hdr1
PRINT @hdr1 + ': ' + @sTmp0
EXEC sp_OAMethod @http, 'GetRequestHeader', @sTmp0 OUT, @hdr2
PRINT @hdr2 + ': ' + @sTmp0
-- Output:
-- X-CSRF-Token: Fetch
-- X-Example: 123ABC
EXEC @hr = sp_OADestroy @http
END
GO
|