Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Populi Add Financial Aid DisbursementDemonstrates the Populi addFinancialAidDisbursement task.
-- 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. -- First load the previously obtained API token. -- See Get Populi Access Token for sample code showing how to get the API token. DECLARE @xml int -- Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Xml', @xml OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int EXEC sp_OAMethod @xml, 'LoadXmlFile', @success OUT, 'qa_data/tokens/populi_token.xml' DECLARE @accessKey nvarchar(4000) EXEC sp_OAMethod @xml, 'GetChildContent', @accessKey OUT, 'access_key' EXEC sp_OAGetProperty @xml, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 <> 1 BEGIN PRINT 'Did not find the access_key' EXEC @hr = sp_OADestroy @xml RETURN END DECLARE @rest int -- Use "Chilkat_9_5_0.Rest" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Rest', @rest OUT -- Connect using TLS. -- A single REST object, once connected, can be used for many Populi REST API calls. -- The auto-reconnect indicates that if the already-established HTTPS connection is closed, -- then it will be automatically re-established as needed. DECLARE @bAutoReconnect int SELECT @bAutoReconnect = 1 EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'yourcollege.populi.co', 443, 1, @bAutoReconnect IF @success <> 1 BEGIN EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @xml EXEC @hr = sp_OADestroy @rest RETURN END EXEC sp_OASetProperty @rest, 'Authorization', @accessKey EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'task', 'addFinancialAidDisbursement' EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'person_id', '12345678' EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'award_id', '555555' EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'academic_term_id', '123' EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'scheduled_date', '2019-10-10' EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'amount', '12345' DECLARE @responseBody nvarchar(4000) EXEC sp_OAMethod @rest, 'FullRequestFormUrlEncoded', @responseBody OUT, 'POST', '/api/index.php' EXEC sp_OAGetProperty @rest, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 <> 1 BEGIN EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @xml EXEC @hr = sp_OADestroy @rest RETURN END -- We should expect a 200 response if successful. EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT IF @iTmp0 <> 200 BEGIN PRINT 'Request Header: ' EXEC sp_OAGetProperty @rest, 'LastRequestHeader', @sTmp0 OUT PRINT @sTmp0 PRINT '----' EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT PRINT 'Response StatusCode = ' + @iTmp0 EXEC sp_OAGetProperty @rest, 'ResponseStatusText', @sTmp0 OUT PRINT 'Response StatusLine: ' + @sTmp0 PRINT 'Response Header:' EXEC sp_OAGetProperty @rest, 'ResponseHeader', @sTmp0 OUT PRINT @sTmp0 PRINT 'Response Body:' PRINT @responseBody EXEC @hr = sp_OADestroy @xml EXEC @hr = sp_OADestroy @rest RETURN END EXEC sp_OAMethod @xml, 'LoadXml', @success OUT, @responseBody EXEC sp_OAMethod @xml, 'GetXml', @sTmp0 OUT PRINT @sTmp0 -- Sample response: -- Use this online tool to generate parsing code from sample XML: -- Generate Parsing Code from XML -- <?xml version="1.0" encoding="UTF-8"?> -- <result> -- <disbursement>123456</disbursement> -- </result> DECLARE @disbursement int EXEC sp_OAMethod @xml, 'GetChildIntValue', @disbursement OUT, 'disbursement' EXEC @hr = sp_OADestroy @xml EXEC @hr = sp_OADestroy @rest END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.