'How to specify request type to AWS lambda invocation with boto3?

I have a lambda function which accepts GET, POST and DELETE requests. I want to invoke it using the boto3 library for python.

According to the documentation, one can invoke a lambda function with boto3 like so:

response = client.invoke(
    FunctionName='string',
    InvocationType='Event'|'RequestResponse'|'DryRun',
    LogType='None'|'Tail',
    ClientContext='string',
    Payload=b'bytes'|file,
    Qualifier='string'
)

But how do I specify my request type? Should my payload contain a field method that has GET/POST/DELETE in it? Or should I pass it through the ClientContext object/string?



Solution 1:[1]

Well, when you invoke the lambda function, it doesn't have option for defining the request type.

Workaround is - you can pass that in your payload and access that in your lambda function.

Otherwise ideal approach is to invoke the function with HTTP request as already suggested.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nishu Tayal