您正在查看 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>
元素。例如,下列政策會透過流程變數
message_weight
指定<MessageWeight>
:<?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"
}
}
}
原因
如果配額政策中未定義 <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>