When API Gateway triggers the execution of a function in Function Compute, data from API Gateway is passed to the event input parameter of the function. You can use this parameter for function debugging.
When you must debug the function code, consider the following:
The format of parameters that are used in the data communication between API Gateway and Function Compute must meet certain requirements.
Before you test a function, you can modify the format of the trigger event in the console.
When Function Compute serves as a backend service of API Gateway, API Gateway passes the request parameters to the
event input parameter of Function Compute in a pre-defined structure. Function Compute obtains the parameters as follows, and then processes the obtained parameters:
"path":"api request path",
"httpMethod":"request method name",
"body":"string of request payload",
Function Compute must return the output to API Gateway in the following
JSON format. Output in this format can be parsed by API Gateway more easily.
To test a function, go to the code editing page of the console and follow these steps:
Click Code Management, click Event, and then write the format of the input parameter from API Gateway into the trigger event.
Click OK to save the test event.
Click Invoke to trigger function execution.