InvokeFunction

Updated at:

Invokes a specified function.

Request syntax

POST /2020-04-30/functions/Function/invocations HTTP/1.1
Cookie: Cookie

Payload
Important 2020-04-30 is the version number of the edge OpenAPI. This value cannot be changed.

Request parameters

Parameter NameTypeRequiredDescription
FunctionStringYesThe information about the function to invoke. The function can be specified in one of the following two ARN formats:
  • Full ARN format: acs:fc:<yourRegion>:<yourAccountId>:service:<yourServiceName>:function:<yourFunctionName>
  • Partial ARN format: service:<yourServiceName>:function:<yourFunctionName>
Important The ARN format must match the following regular expression pattern.

(^acs:fc:([a-z]{2}-[a-z]+(-\d)?)?:(\d{16})?:)?service:([a-zA-Z][\w-]{0,127}):function:([a-zA-Z][\w-]{0,127})$

CookieStringYesThe authentication cookie created by calling the CreateAuthCookie operation.
PayloadJSONYesThe content of the payload is passed to the function without modification.

Return syntax

HTTP/1.1 StatusCode
X-Fc-Error-Type: ErrorType

Payload

Response parameters

Parameter NameTypeDescription
StatusCodeNumberThe HTTP status code. A value of 200 indicates that the call is successful. Other values indicate that the call failed. For more information, see Status codes.
ErrorTypeStringThis parameter is returned when an error occurs during function execution. It can be one of the following values:
  • Handled: An error reported by the function.
  • Unhandled: An error detected and reported by Function Compute, such as a function timeout or an out-of-memory error.
PayloadJSONThe content that the function returns. If an error occurs, this parameter contains an error message.

The response payload is in the following format.

{
    "Message": "string",
    "StackTrace": []
}

Examples

$ curl -i -b token.cookie -k -X POST https://127.0.0.1:9999/2020-04-30/functions/service:helloworld:function:helloworld/invocations

HTTP/1.1 200 OK
Server: openresty/1.13.6.2
Date: Tue, 21 Apr 2020 14:37:38 GMT
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive

Hello World