![]() |
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
(Lianja) Call an AWS Lambda FunctionDemonstrates how to call an AWS Lambda function.
llSuccess = .F. // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loRest = createobject("CkRest") // Connect to the Amazon AWS REST server. // such as https://email.us-west-2.amazonaws.com/ llBTls = .T. lnPort = 443 llBAutoReconnect = .T. // ------------------------------------------------------------------------------------------- // 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: llSuccess = loRest.Connect("itwxyj3vd6gjtaerbfqnfccs2e0fplzh.lambda-url.us-west-2.on.aws",lnPort,llBTls,llBAutoReconnect) // Provide AWS credentials for the REST call. loAuthAws = createobject("CkAuthAws") 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("CkJsonObject") loJson.UpdateString("name","Benny") loRest.AddHeader("Content-Type","application/json") loSbRequestBody = createobject("CkStringBuilder") loJson.EmitSb(loSbRequestBody) loSbResponseBody = createobject("CkStringBuilder") llSuccess = loRest.FullRequestSb("POST","/",loSbRequestBody,loSbResponseBody) if (llSuccess = .F.) then ? loRest.LastErrorText release loRest release loAuthAws release loJson release loSbRequestBody release loSbResponseBody return 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 return endif ? "Response Body:" ? loSbResponseBody.GetAsString() release loRest release loAuthAws release loJson release loSbRequestBody release loSbResponseBody
|
||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.