![]() |
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
(AutoIt) Call an AWS Lambda FunctionDemonstrates how to call an AWS Lambda function.
Local $bSuccess = False ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oRest = ObjCreate("Chilkat.Rest") ; Connect to the Amazon AWS REST server. ; such as https://email.us-west-2.amazonaws.com/ Local $bTls = True Local $iPort = 443 Local $bAutoReconnect = True ; ------------------------------------------------------------------------------------------- ; 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: $bSuccess = $oRest.Connect("itwxyj3vd6gjtaerbfqnfccs2e0fplzh.lambda-url.us-west-2.on.aws",$iPort,$bTls,$bAutoReconnect) ; Provide AWS credentials for the REST call. $oAuthAws = ObjCreate("Chilkat.AuthAws") $oAuthAws.AccessKey = "AWS_ACCESS_KEY" $oAuthAws.SecretKey = "AWS_SECRET_KEY" ; the region should match our domain above.. $oAuthAws.Region = "us-west-2" $oAuthAws.ServiceName = "lambda" $oRest.SetAuthAws($oAuthAws) $oJson = ObjCreate("Chilkat.JsonObject") $oJson.UpdateString("name","Benny") $oRest.AddHeader("Content-Type","application/json") $oSbRequestBody = ObjCreate("Chilkat.StringBuilder") $oJson.EmitSb($oSbRequestBody) $oSbResponseBody = ObjCreate("Chilkat.StringBuilder") $bSuccess = $oRest.FullRequestSb("POST","/",$oSbRequestBody,$oSbResponseBody) If ($bSuccess = False) Then ConsoleWrite($oRest.LastErrorText & @CRLF) Exit EndIf Local $iStatusCode = $oRest.ResponseStatusCode If ($iStatusCode >= 400) Then ConsoleWrite("Response Status Code: " & $iStatusCode & @CRLF) ConsoleWrite("Response Body: " & $oSbResponseBody.GetAsString() & @CRLF) ConsoleWrite("Failed." & @CRLF) Exit EndIf ConsoleWrite("Response Body:" & @CRLF) ConsoleWrite($oSbResponseBody.GetAsString() & @CRLF)
|
||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.