# Trigger Cloud Function

Debugging tools

Interface should be called on the server side, seeHattori API

# Interface Dxplaination

# Interface name

invokeCloudFunction

# Functional description

Cloud functions can be triggered through this interface. If you encounter problems during use, you canOpen Platform Service Provider ZonePosting exchanges

# Note

  • Use this API Trigger the cloud function, in which you cannot get the OpenID Other APIs involving user login are not available.
  • Be careful POST BODY Part is passed to the cloud function as an input parameter.
  • by HTTP API The triggered cloud function can be invoked using the cloud.
  • by HTTP API The timeout to trigger the cloud function is 5 s, please note that the cloud function cannot be executed for too long.
  • If it is a service provider model - batch generation cloud development, use component_access_Token
  • If it is a service provider model - general generation cloud development, use authorizer_access_Token
  • If it is a common call to a Mini Program, use access_token。

# Calling mode

# HTTPS call


POST New https://api.weixin.qq.com/tcb/invokecloudfunction?access_token=ACCESS_TOKEN 

# Third Party Invocation

  • The calling method and parameters are the same as HTTPS, only the calling token is different

  • The permission set id to which this interface belongs is: 49, 64

  • After the service provider has been authorized with one of the permission sets, it can do so by usingauthorizer_access_TokenCalling on behalf of the merchant

# Request parameters

attribute type Required Introductions
access_Token string yes Interface invokes the certificate, which is URL Parameters, non Body Parameters. useaccess_Tokenorauthorizer_access_Token
env string yes Cloud Development Environment ID
name string yes Cloud Function Name
req_data string yes The incoming parameters of the cloud function, the exact structure is defined by the developer

# Return parameters

attribute type Introductions
errcode number Error code
errmsg string Error message
resp_data string Buffer returned by the cloud function

# Call Example

Example Dxplaination: CURL Request Example

# Sample Request Data


curl -d '{}' 
'https://api.weixin.qq.com/tcb/invokecloudfunction?access_token=ACCESS_TOKEN&env=ENV&name=login' 

# Return Data Example


{
    "errcode": 0,
    "errmsg": "ok",
    "resp_data": "{"event":{"userInfo":{"appId":"SAMPLE_APPID"}},"appid":"SAMPLE_APPID"}"
} 

# Error code

Error code Error code Solutions
-1 system error The system is busy, please wait for the developer to try again
40014 invalid access_Token Illegal access_Token Please take the developer seriously. access_Token Of the validity (such as whether it is expired), or to see if you are working for the appropriate Official Account message template Call interface
40101 missing parameter Missing required parameters
41001 access_Token missing lack access_Token parameter
42001 access_Token expired access_Token Timeout, please check access_Token Of the validity period, please refer to the Basic Support - Obtain access_Token Middle, right. access_Token Detailed mechanism explaination of the
43002 require POST method Need POST request
44002 empty post data POST Of the packet is empty. The post request body parameter cannot be null.
85088 no qbase privilege The app is not open for cloud development