Invokes a function.
Request headersThis operation uses only common request headers. For more information, see Common parameters.
Parameter Type Required Examples Description X-Fc-Invocation-Type String No SyncThe invocation method. Valid values:
The method used to return logs. Valid values:
The ID of the asynchronous task. You must enable the asynchronous task feature in advance.
Note When you use an SDK to invoke a function, we recommend that you specify a business-related ID to facilitate subsequent operations. For example, you can use the video name as the invocation ID for a video-processing function. After that, you can use the ID to check whether the video is processed or terminate the processing of the video. The ID must start with a letter or an underscore (_), and can contain letters, digits, underscores (_), and hyphens (-). The ID can be up to 128 characters in length. If you do not specify the ID of the asynchronous invocation, Function Compute automatically generates an ID.
Request syntaxPOST /services/{serviceName.qualifier}/functions/{functionName} HTTP/1.1
Request parameters Parameter Type Location Required Example Description serviceName String Path Yes service_name
The name of the service.
qualifier String Path No LATESTThe version or alias of the service.
functionName String Path Yes function_nameThe name of the function.
String Body Yes {"key1": "value1"}The event of the function. The value of this parameter is a binary array. Function Compute passes the event to the function for processing.
Response parameters Parameter Type Example Description X-Fc-Error-Type String UnhandledInvocationErrorThe type of errors returned after the function is invoked. Valid values:
HandledInvocationError
type. For more information, see Error handling.The returned log results.
X-Fc-Code-Checksum String 5697641582914695457The CRC-64 value of the function code package.
X-Fc-Stateful-Async-Invocation-Id String g6u*****iyvhd3jk8s6bhj0hhThe ID of the asynchronous task. You must enable the asynchronous task feature in advance.
Note When you use an SDK to invoke a function, we recommend that you specify a business-related ID to facilitate subsequent operations. For example, you can use the video name as the invocation ID for a video-processing function. After that, you can use the ID to check whether the video is processed or terminate the processing of the video. The ID must start with a letter or an underscore (_), and can contain letters, digits, underscores (_), and hyphens (-). The ID can be up to 128 characters in length. Function Compute generates an ID for the asynchronous task if it is not specified.
X-Fc-Instance-Id String 7c43576b-48b1-4c3a-86e5-dcb01872****The ID of the function instance.
X-Fc-Request-Id String dab25e58-9356-4e3f-97d6-f044c4****The request ID of the function invocation.
X-Fc-Max-Memory-Usage String 9.2The memory consumed by the function execution. Unit: MB.
X-Fc-Invocation-Duration String 10The duration consumed by the function execution, in milliseconds.
X-Fc-Invocation-Service-Version String LATESTThe version or alias of the called function.
String hello worldThe result returned after the function is invoked. You can specify the result returned.
ExamplesSample requests
POST /services/{serviceName.qualifier}/functions/function_name HTTP/1.1
Host:fc-ram.aliyuncs.com
X-Fc-Invocation-Type:Sync
X-Fc-Log-Type:None
X-Fc-Stateful-Async-Invocation-Id:g6u*****iyvhd3jk8s6bhj0hh
Content-Type:application/json
{"key1": "value1"}
Sample success responses
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"result" : "hello world"
}
Thank you! We've received your feedback.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4