tencent cloud

文档反馈

InvokeFunction

最后更新时间:2023-07-18 11:11:02

1. API Description

Domain name for API request: scf.tencentcloudapi.com.

This API is used to invoke functions synchronously.

A maximum of 10000 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: InvokeFunction.
Version Yes String Common Params. The value used for this API: 2018-04-16.
Region No String Common Params. This parameter is not required for this API.
FunctionName Yes String Function name
Qualifier No String Version or alias of the function. It defaults to $DEFAULT.
Event No String Function running parameter, which is in the JSON format. Maximum parameter size is 6 MB. This field corresponds to event input parameter.
LogType No String Valid value: None (default) or Tail. If the value is Tail, log in the response will contain the corresponding function execution log (up to 4KB).
Namespace No String Namespace. default is used if it’s left empty.
RoutingKey No String Traffic routing config in json format, e.g., {"k":"v"}. Please note that both "k" and "v" must be strings. Up to 1024 bytes allowed.

3. Output Parameters

Parameter Name Type Description
Result Result Function execution result
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Running a function

Input Example

https://scf.tencentcloudapi.com/?Action=InvokeFunction
&FunctionName=xxxx
&<Common request parameters>

Output Example

{
    "Response": {
        "Result": {
            "MemUsage": 3207168,
            "Log": "",
            "RetMsg": "hello from scf",
            "BillDuration": 100,
            "FunctionRequestId": "6add56fa-58f1-11e8-89a9-5254005d5fdb",
            "Duration": 0.826,
            "ErrMsg": "",
            "InvokeResult": 0
        },
        "RequestId": "c2af8a64-c922-4d55-aee0-bd86a5c2cd12"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.FunctionStatusError Operation failed. The function is deploying.
FailedOperation.InvokeFunction Failed to invoke the function.
InternalError Internal error.
InternalError.System Internal system error.
InvalidParameter.FunctionName The value of FunctionName does not conform to the specification. Please fix it and try again. For more information, please visit https://tencentcs.com/5jXKFnBW.
InvalidParameter.RequestTooLarge Request size
InvalidParameterValue Incorrect parameter value.
InvalidParameterValue.ClientContext Function running parameter error
InvalidParameterValue.FunctionType FunctionType error
InvalidParameterValue.Param The input parameter is not in the standard JSON format.
LimitExceeded.Quota Reached the upper limit of quota
ResourceNotFound.Function The function does not exist.
ResourceNotFound.FunctionName The function does not exist.
ResourceNotFound.Qualifier The version does not exist.
ResourceUnavailable.InsufficientBalance Your balance is insufficient. Please top up first.
UnauthorizedOperation.CAM CAM authentication failed.
联系我们

联系我们,为您的业务提供专属服务。

技术支持

如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

7x24 电话支持