您目前查看的是 Apigee 和 Apigee Hybrid 說明文件。
查看
Apigee Edge 說明文件。
InvalidMessageWeight
錯誤代碼
policies.ratelimit.InvalidMessageWeight
錯誤回應主體
{
"fault": {
"faultstring": "Invalid message weight value [invalid_value]",
"detail": {
"errorcode": "policies.ratelimit.InvalidMessageWeight"
}
}
}
錯誤訊息範例
{
"fault": {
"faultstring": "Invalid message weight value 1.5",
"detail": {
"errorcode": "policies.ratelimit.InvalidMessageWeight"
}
}
}
原因
如果透過流程變數指定的 <MessageWeight> 元素值無效 (非整數值),就會發生這個錯誤。
舉例來說,如果為 <MessageWeight> 元素指定的流程變數值為 1.5 (非整數值),就會發生這項錯誤。
診斷
找出配額政策中
<MessageWeight>元素使用的無效值。您可以在錯誤回應的faultstring元素中找到這項資訊。舉例來說,在下列錯誤中,<MessageWeight>元素使用的無效值為1.5:"faultstring": "Invalid message weight value 1.5"檢查發生失敗的特定 API Proxy 中的所有配額政策。可能有一或多項配額政策指定了
<MessageWeight>元素。舉例來說,下列政策會透過流程變數
<MessageWeight>指定message_weight:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Quota async="false" continueOnError="false" enabled="true" name="Quota_with_weight" type="calendar"> <DisplayName>Quota_with_weight</DisplayName> <Properties/> <Allow count="3"/> <Interval>1</Interval> <TimeUnit>minute</TimeUnit> <StartTime>2017-7-16 12:00:00</StartTime> <MessageWeight ref="message_weight"/> </Quota>在已識別的配額政策中,判斷用於
<MessageWeight>的變數值。流程變數的值可以從 HTTP 標頭、查詢參數、XML 或 JSON 要求酬載中擷取,也可以在其他政策中定義:- 在 API Proxy 套件中,找出變數的定義位置。
- 找出變數定義和填入的第一個政策後,請檢查變數值的設定方式。
- 如果流程變數的值與上述步驟 1 中識別的值相符,則這就是錯誤原因。
舉例來說,假設配額政策之前的 JavaScript 政策會根據要求類型設定變數
message_weight,如下所示:var verb = context.getVariable("request.verb"); context.setVariable("message_weight", "1.5"); if (verb == 'POST') { context.setVariable("message_weight", "2"); }請注意,變數
message_weight的值為1.5,這是無效值 (非整數)。
解析度
確認流程變數指定的 MessageWeight 值是有效值 (整數值)。
如要修正上述範例,您可以將 JavaScript 中變數 message_weight 的值修改為整數。
var verb = context.getVariable("request.verb");
context.setVariable("message_weight", "1");
if (verb == 'POST') {
context.setVariable("message_weight", "2");
}
FailedToResolveQuotaIntervalReference
錯誤代碼
policies.ratelimit.FailedToResolveQuotaIntervalReference
錯誤回應主體
{
"fault": {
"faultstring": "Failed to resolve quota interval reference [reference] in quota policy {1}",
"detail": {
"errorcode": "policies.ratelimit.FailedToResolveQuotaIntervalReference"
}
}
}
錯誤訊息範例
{
"fault": {
"faultstring": "Failed to resolve quota interval reference api.product.developer.quota.interval in quota policy {1}",
"detail": {
"errorcode": "policies.ratelimit.FailedToResolveQuotaIntervalReference"
}
}
}
原因
如果配額政策中未定義 <Interval> 元素,就會發生這個錯誤。這個元素為必要元素,用於指定配額適用的時間間隔。時間間隔可以是分鐘、小時、天、週或月,如 <TimeUnit> 元素所定義。
診斷
檢查發生失敗的 API Proxy 中的每項配額政策。如果配額政策未定義必要元素
<Interval>,就會導致錯誤。舉例來說,下列配額政策缺少必要元素
<Interval>:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Quota async="false" continueOnError="false" enabled="true" name="CheckQuota" type="calendar"> <DisplayName>CheckQuota</DisplayName> <Properties/> <Allow count="3"/> <TimeUnit ref="verifyapikey.verify-api-key.apiproduct.developer.quota.timeunit">hour</TimeUnit> <StartTime>2017-7-16 12:00:00</StartTime> </Quota>由於上述配額政策中未定義必要元素
<TimeUnit>,您會收到下列錯誤碼:policies.ratelimit.FailedToResolveQuotaIntervalReference
解析度
請確保特定 API Proxy 的所有配額政策都已正確定義必要元素 <Interval>。
如要修正上述範例,可以修改政策,加入 <Interval> 元素,如下所示。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Quota async="false" continueOnError="false" enabled="true" name="CheckQuota" type="calendar"> <DisplayName>CheckQuota</DisplayName> <Properties/> <Allow count="3"/> <TimeUnit ref="verifyapikey.verify-api-key.apiproduct.developer.quota.timeunit">hour</TimeUnit> <Interval ref="verifyapikey.verify-api-key.apiproduct.developer.quota.interval">1</Interval> <StartTime>2017-7-16 12:00:00</StartTime> </Quota>
FailedToResolveQuotaIntervalTimeUnitReference
錯誤代碼
policies.ratelimit.FailedToResolveQuotaIntervalTimeUnitReference
錯誤回應主體
{
"fault": {
"faultstring": "Failed to resolve quota time unit reference [reference] in quota policy {1}",
"detail": {
"errorcode": "policies.ratelimit.FailedToResolveQuotaIntervalTimeUnitReference"
}
}
}
錯誤訊息範例
{
"fault": {
"faultstring": "Failed to resolve quota time unit reference apiproduct.developer.quota.timeunity in quota policy {1}",
"detail": {
"errorcode": "policies.ratelimit.FailedToResolveQuotaIntervalTimeUnitReference"
}
}
}
原因
如果 Quota 政策中未定義 <TimeUnit> 元素,就會發生這個錯誤。這個元素為必填,用於指定適用於配額的時間單位。時間間隔可以分鐘、小時、天、週或月為單位。
診斷
檢查發生失敗的 API Proxy 中的每項配額政策。如果任何配額政策未定義必要元素
<TimeUnit>,就會導致錯誤。舉例來說,下列配額政策缺少必要元素
<TimeUnit>:<Quota async="false" continueOnError="false" enabled="true" name="CheckQuota" type="calendar"> <DisplayName>CheckQuota</DisplayName> <Properties/> <Allow count="3"/> <Interval ref="verifyapikey.verify-api-key.apiproduct.developer.quota.interval">1</Interval> <StartTime>2017-7-16 12:00:00</StartTime> </Quota>由於上述配額政策中未定義必要元素
<TimeUnit>,您會收到下列錯誤碼:policies.ratelimit.FailedToResolveQuotaIntervalTimeUnitReference
解析度
請確保特定 API Proxy 的所有配額政策都已定義必要元素 <TimeUnit>。
如要修正上述範例,可以修改政策,加入 <TimeUnit> 元素,如下所示。
<Quota async="false" continueOnError="false" enabled="true" name="CheckQuota" type="calendar"> <DisplayName>CheckQuota</DisplayName> <Properties/> <Allow count="3"/> <TimeUnit ref="verifyapikey.verify-api-key.apiproduct.developer.quota.timeunit">hour</TimeUnit> <Interval ref="verifyapikey.verify-api-key.apiproduct.developer.quota.interval">1</Interval> <StartTime>2017-7-16 12:00:00</StartTime> </Quota>