![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Call an AWS Lambda FunctionDemonstrates how to call an AWS Lambda function.
LOCAL lnSuccess LOCAL loRest LOCAL lnBTls LOCAL lnPort LOCAL lnBAutoReconnect LOCAL loAuthAws LOCAL loJson LOCAL loSbRequestBody LOCAL loSbResponseBody LOCAL lnStatusCode lnSuccess = 0 * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. loRest = CreateObject('Chilkat.Rest') * Connect to the Amazon AWS REST server. * such as https://email.us-west-2.amazonaws.com/ lnBTls = 1 lnPort = 443 lnBAutoReconnect = 1 * ------------------------------------------------------------------------------------------- * Note: The source of the lambda function (hosted on AWS) is shown at the bottom of this page. * -------------------------------------------------------------------------------------------- * If your lambda function URL is: https://itwxyj3vd6gjtaerbfqnfccs2e0fplzh.lambda-url.us-west-2.on.aws/ * then use just the domain part here: lnSuccess = loRest.Connect("itwxyj3vd6gjtaerbfqnfccs2e0fplzh.lambda-url.us-west-2.on.aws",lnPort,lnBTls,lnBAutoReconnect) * Provide AWS credentials for the REST call. loAuthAws = CreateObject('Chilkat.AuthAws') loAuthAws.AccessKey = "AWS_ACCESS_KEY" loAuthAws.SecretKey = "AWS_SECRET_KEY" * the region should match our domain above.. loAuthAws.Region = "us-west-2" loAuthAws.ServiceName = "lambda" loRest.SetAuthAws(loAuthAws) loJson = CreateObject('Chilkat.JsonObject') loJson.UpdateString("name","Benny") loRest.AddHeader("Content-Type","application/json") loSbRequestBody = CreateObject('Chilkat.StringBuilder') loJson.EmitSb(loSbRequestBody) loSbResponseBody = CreateObject('Chilkat.StringBuilder') lnSuccess = loRest.FullRequestSb("POST","/",loSbRequestBody,loSbResponseBody) IF (lnSuccess = 0) THEN ? loRest.LastErrorText RELEASE loRest RELEASE loAuthAws RELEASE loJson RELEASE loSbRequestBody RELEASE loSbResponseBody CANCEL ENDIF lnStatusCode = loRest.ResponseStatusCode IF (lnStatusCode >= 400) THEN ? "Response Status Code: " + STR(lnStatusCode) ? "Response Body: " + loSbResponseBody.GetAsString() ? "Failed." RELEASE loRest RELEASE loAuthAws RELEASE loJson RELEASE loSbRequestBody RELEASE loSbResponseBody CANCEL ENDIF ? "Response Body:" ? loSbResponseBody.GetAsString() RELEASE loRest RELEASE loAuthAws RELEASE loJson RELEASE loSbRequestBody RELEASE loSbResponseBody
|
||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.