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
(Visual FoxPro) RSAP Union API - Get Members StatusDemonstrates how to use an OAuth2 access token for the RSAP Union API. Calls the endpoint to get the statuses of all union members. For more information, see https://app.swaggerhub.com/apis-docs/pderas/RSAP/2.0.1#/Members/getAllUnionMemberStatuses
LOCAL loHttp LOCAL lnSuccess LOCAL loJToken LOCAL loCert LOCAL loPrivKey LOCAL loSbResponseBody LOCAL loJResp LOCAL lnRespStatusCode * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * Load the access token previously obtained by this example: RSAP Union OAuth2 * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJToken = CreateObject('Chilkat.JsonObject') lnSuccess = loJToken.LoadFile("qa_data/tokens/rsapToken.json") IF (lnSuccess = 0) THEN ? "Failed to load access token JSON." RELEASE loHttp RELEASE loJToken CANCEL ENDIF * Adds the "Authorization: Bearer ACCESS_TOKEN" header. loHttp.AuthToken = loJToken.StringOf("access_token") * For authentication, assuming both the client cert and access token are needed??? * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Cert') loCert = CreateObject('Chilkat.Cert') lnSuccess = loCert.LoadFromFile("qa_data/certs_and_keys/union_client_certificate.crt") IF (lnSuccess = 0) THEN ? loCert.LastErrorText RELEASE loHttp RELEASE loJToken RELEASE loCert CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.PrivateKey') loPrivKey = CreateObject('Chilkat.PrivateKey') lnSuccess = loPrivKey.LoadAnyFormatFile("qa_data/certs_and_keys/union_client_certificate.nopass.key","") IF (lnSuccess = 0) THEN ? loPrivKey.LastErrorText RELEASE loHttp RELEASE loJToken RELEASE loCert RELEASE loPrivKey CANCEL ENDIF * Associate the private key with the cert. * This will fail if the private key is not actually the correct one that corresponds to the public key stored within the cert. lnSuccess = loCert.SetPrivateKey(loPrivKey) IF (lnSuccess = 0) THEN ? loCert.LastErrorText RELEASE loHttp RELEASE loJToken RELEASE loCert RELEASE loPrivKey CANCEL ENDIF * Tell HTTP to use the cert for client TLS certificate authentication. lnSuccess = loHttp.SetSslClientCert(loCert) IF (lnSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loJToken RELEASE loCert RELEASE loPrivKey CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') lnSuccess = loHttp.QuickGetSb("https://api-test.rsap.ca/members/status",loSbResponseBody) IF (lnSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loJToken RELEASE loCert RELEASE loPrivKey RELEASE loSbResponseBody CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.JsonObject') loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = 0 ? "Response Body:" ? loJResp.Emit() lnRespStatusCode = loHttp.LastStatus ? "Response Status Code = " + STR(lnRespStatusCode) IF (lnRespStatusCode >= 400) THEN ? "Response Header:" ? loHttp.LastHeader ? "Failed." RELEASE loHttp RELEASE loJToken RELEASE loCert RELEASE loPrivKey RELEASE loSbResponseBody RELEASE loJResp CANCEL ENDIF RELEASE loHttp RELEASE loJToken RELEASE loCert RELEASE loPrivKey RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.