# 获取电子面单余额
接口应在服务器端调用,不可在前端(小程序、网页、APP等)直接调用,具体可参考接口调用指南
接口英文名:getQuota
该接口用于获取电子面单余额。仅在使用加盟类快递公司时,才可以调用。
# 1. 调用方式
# HTTPS 调用
POST https://api.weixin.qq.com/cgi-bin/express/business/quota/get?access_token=ACCESS_TOKEN
# 云调用
调用方法:logistics.getQuota
出入参和 HTTPS 调用相同,调用方式可查看 云调用 说明文档
# 第三方调用
本接口支持第三方平台代商家调用。
该接口所属的权限集 id 为:45、71
服务商获得其中之一权限集授权后,可通过使用 authorizer_access_token 代商家进行调用,具体可查看 第三方调用 说明文档。
# 2. 请求参数
# 查询参数 Query String parameters
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| access_token | string | 是 | 接口调用凭证,可使用 access_token、authorizer_access_token |
# 请求体 Request Payload
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| delivery_id | string | 是 | 快递公司ID,参见getAllDelivery |
| biz_id | string | 是 | 快递公司客户编码 |
# 3. 返回参数
# 返回体 Response Payload
| 参数名 | 类型 | 说明 |
|---|---|---|
| quota_num | number | 电子面单余额 |
| errcode | number | 接口报错时返回,错误码 |
| errmsg | string | 接口报错时返回,错误信息 |
# 4. 注意事项
本接口无特殊注意事项
# 5. 代码示例
# 5.1 HTTPS调用
请求示例
{
"delivery_id": "YTO",
"biz_id": "xyz"
}
返回示例
{
"quota_num": 210
}
# 5.2 云函数调用
请求示例
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.logistics.getQuota({
"deliveryId": 'YTO',
"bizId": 'xyz'
})
return result
} catch (err) {
return err
}
}
返回示例
{
"quotaNum": 210,
"errMsg": "openapi.logistics.getQuota:ok"
}
# 6. 错误码
以下是本接口的错误码列表,其他错误码可参考 通用错误码;调用接口遇到报错,可使用官方提供的 API 诊断工具 辅助定位和分析问题。
| 错误码 | 错误描述 | 解决方案 |
|---|---|---|
| 40001 | invalid credential access_token isinvalid or not latest | 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口 |
# 7. 适用范围
本接口支持「小程序(仅认证)」账号类型调用。其他账号类型如无特殊说明,均不可调用。