This topic describes how to troubleshoot issues that may occur when you use Function Compute as a backend service of API Gateway.
Error code 503 is returned when function execution is triggered by API Gateway but the function log shows that the function has been executed. How do I resolve this issue?
API Gateway requires Function Compute to return responses in a specific format. If the returned result is not in the expected format, API Gateway considers the backend service to be unavailable. For more information about the format requirements, see Author functions.
How do I set the content type of the returned response?
As shown in the figure, you can set the content type of a response when you set the API operation. For more information, see Create a API.
Error code 503 is returned when I call a function that has been previously called, but has not been called for a period of time. How do I resolve this issue?
If a function has not been called for a period of time, a new execution environment must be prepared when the function is called again, causing a cold start delay. This may make the call not be completed within the timeout period, leading API Gateway to consider the backend service to be unavailable. To resolve this issue, set the timeout period of API Gateway to a larger value.
Why are the bodies of the requests passed from API Gateway to Function Compute encoded in Base64?
The bodies of the requests are encoded in Base64 to prevent content transmission errors or loss. Bodies in form format transmitted by API Gateway are not Base64-encoded. You must select Input Parameter Mapping in API Gateway when you transmit bodies in form format. We recommend that you check whether the value of the isBase64 field in the event is true before you decode events in the function. If the isBase64 field is set to true, you need to decode the request bodies. For more information about the formats of events that API Gateway passes to Function Compute, see Author functions.