How to Resolve Cloud Call Error -604101
When invoking Cloud Call APIs (such as security.msgSecCheck, security.imgSecCheck, etc.) in WeChat CloudBase, you may encounter the -604101 error code with the message system error: error code: -604101.
Symptoms
When calling Cloud Call-related APIs, the following error is returned:
{
"errCode": -604101,
"errMsg": "system error: error code: -604101"
}
Or the complete log resembles:
Error: errCode: -604101 | errMsg: openapi.security.msgSecCheck:fail system error: error code: -604101
Causes
Cloud Calls require declaring the permissions of the APIs to be used in the config.json file in the Cloud Function directory. If permissions are not configured correctly, a -604101 error will be returned upon invocation.
Solutions
Step 1: Create or Modify config.json
Create or modify the config.json file in the Cloud Function directory to add the declaration of the required API permissions.
Example file structure:
cloudfunctions/
└── myFunction/
├── index.js
├── package.json
└── config.json # Add this file
Step 2: Configure API Permissions
Declare the required APIs in the permissions.openapi field in config.json:
{
"permissions": {
"openapi": [
"security.msgSecCheck",
"security.imgSecCheck",
"security.mediaCheckAsync"
]
}
}
Common API examples:
| API Name | Purpose |
|---|---|
security.msgSecCheck | Text content security check |
security.imgSecCheck | Image content security check |
security.mediaCheckAsync | Asynchronous media content security check (recommended) |
templateMessage.send | Send template messages |
subscribeMessage.send | Send subscription messages |
Step 3: Re-upload the Cloud Function
Use WeChat DevTools to re-upload the Cloud Function to apply the permission configuration.
Step 4: Wait for the Cache to Expire
The permission configuration has a cache time of approximately 10 minutes. If errors still occur after uploading, please wait 10 minutes and try again.
Complete Example
config.json:
{
"permissions": {
"openapi": [
"security.msgSecCheck"
]
}
}
index.js:
const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.security.msgSecCheck({
content: event.content
})
return result
} catch (err) {
console.error(err)
return { errCode: err.errCode, errMsg: err.errMsg }
}
}
Considerations
permissions.openapiis an array of strings, and each element is an API name.- The API names must match the API names in the official documentation exactly.
- Every time you modify
config.json, you must re-upload the Cloud Function. - It is recommended to use
security.mediaCheckAsyncinstead ofsecurity.imgSecCheckas a priority.
FAQ
- How do I resolve Cloud Call error -604101?
- What should I do if a WeChat CloudBase OpenAPI call fails?
- What is the reason for security.msgSecCheck returning a -604101 error?
- How do I handle permission denial when calling WeChat Open APIs in a Cloud Function?
- How do I configure Cloud Call permissions in config.json?
- Where do I set the Cloud Call permission configuration?
- How long does it take for permissions to take effect after uploading a Cloud Function?
- How do I resolve OpenAPI call failed system errors?
- How do I write permissions.openapi in a Cloud Function?
- What is the permission declaration format for WeChat CloudBase?