SQL Server
SQL Server
POST XML to https://apicert.sii.cl/recursos/v1/boleta.electronica.token
See more HTTP Misc Examples
Demonstrates how to send an HTTPS POST XML request to POST XML to https://apicert.sii.cl/recursos/v1/boleta.electronica.token and retrieve the response.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)
DECLARE @success int
SELECT @success = 0
-- 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
-- XML to send in the body of the HTTPS POST
DECLARE @xmlStr nvarchar(4000)
SELECT @xmlStr = '...'
DECLARE @urlEndpoint nvarchar(4000)
SELECT @urlEndpoint = 'https://apicert.sii.cl/recursos/v1/boleta.electronica.token'
DECLARE @xmlCharset nvarchar(4000)
SELECT @xmlCharset = 'utf-8'
DECLARE @resp int
EXEC @hr = sp_OACreate 'Chilkat.HttpResponse', @resp OUT
EXEC sp_OAMethod @http, 'HttpStr', @success OUT, 'POST', @urlEndpoint, @xmlStr, 'utf-8', 'application/xml', @resp
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @resp
RETURN
END
-- Get the response status code and body
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT 'response status code = ' + @iTmp0
-- This would be the XML response sent by the server.
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @resp
END
GO