您目前查看的是 Apigee 和 Apigee Hybrid 說明文件。
查看
Apigee Edge 說明文件。
ExecutionFailed
錯誤代碼
steps.jsonthreatprotection.ExecutionFailed
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name]: Execution failed. reason: JSONThreatProtection[policy_name]: error_description at line line_num", "detail": { "errorcode": "steps.jsonthreatprotection.ExecutionFailed" } } }
錯誤類型和可能原因
JSONThreatProtection 政策可能會擲回多種 ExecutionFailed 錯誤。下表列出不同類型的錯誤和可能原因:
| 錯誤類型 | 原因 |
| 物件項目名稱長度超過上限 | 物件項目名稱的字串長度超過上限。 |
| 超過物件項目數量上限 | 物件中的項目數量已超過上限。 |
| 陣列元素數量超過上限 | 陣列中的元素數量已超過上限。 |
| 超過容器深度 | 超過允許的巢狀結構深度上限。 |
| 字串值長度超出上限 | 字串值超過允許的長度上限。 |
| 無效的 JSON 物件 | 輸入的 JSON 酬載無效。 |
物件項目名稱長度超過上限
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name]: Execution failed. reason: JSONThreatProtection[policy_name]: Exceeded object entry name length at line line_num", "detail": { "errorcode": "steps.jsonthreatprotection.ExecutionFailed" } } }
錯誤回應主體範例
{
"fault": {
"faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
Exceeded object entry name length at line 2",
"detail": {
"errorcode": "steps.jsonthreatprotection.ExecutionFailed"
}
}
}
原因
如果 <Source> 元素指定的輸入訊息酬載包含的 JSON 物件,其屬性名稱超過 <ObjectEntryNameLength> 元素中指定長度上限,就會發生這個錯誤。
舉例來說,如果政策中的 <ObjectEntryNameLength> 元素指定為 5,但輸入訊息酬載的 JSON 屬性名稱超過 5 個字元,就會擲回這項錯誤。
診斷
檢查錯誤訊息,找出 JSONThreatProtection 政策名稱,以及長項目名稱出現的行號。舉例來說,在下列錯誤訊息中,JSONThreatProtection 政策名稱為
JSON-Threat-Protection-1,酬載中的行號為 2。JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded object entry name length at line 2檢查您在步驟 1 中找到的政策,並記下
<ObjectEntryNameLength>元素中指定的值。舉例來說,在下列 JSONThreatProtection 政策中,
<ObjectEntryNameLength>會設為5:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1"> <DisplayName>JSON Threat Protection-1</DisplayName> <Properties/> <ArrayElementCount>3</ArrayElementCount> <ContainerDepth>12</ContainerDepth> <ObjectEntryCount>5</ObjectEntryCount> <ObjectEntryNameLength>5</ObjectEntryNameLength> <Source>request</Source> <StringValueLength>50</StringValueLength> </JSONThreatProtection>檢查輸入內容的特定行號 (在步驟 1 中識別),並確認物件名稱的長度是否大於
<ObjectEntryNameLength>元素 (在步驟 2 中識別) 中指定的值。如果物件名稱長度超過該數字,就是造成錯誤的原因。以下是輸入酬載範例:
{ "number" : 500, "string" : "text" }如上所示,JSON 酬載在第 2 行有一個名為
number的屬性,長度為 6 個字元 (名稱長度為 6)。由於物件名稱的長度大於 5 (為<ObjectEntryNameLength>元素指定的值),您會收到下列錯誤訊息:JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded object entry name length at line 2
解析度
如果 JSONThreatProtection 政策的目的是防範物件項目名稱超過定義值的酬載,則會顯示錯誤訊息。在這種情況下,您不需要採取其他行動。
不過,如果您判斷可以在酬載中指定較長的物件項目名稱,且不會造成任何後果,請根據需求將 <ObjectEntryNameLength> 修改為適當的值。
舉例來說,如果您認為可以允許物件名稱長度最多 10 個字元,請依下列方式修改 JSONThreatProtection 政策:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
<DisplayName>JSON Threat Protection-1</DisplayName>
<Properties/>
<ArrayElementCount>3</ArrayElementCount>
<ContainerDepth>12</ContainerDepth>
<ObjectEntryCount>5</ObjectEntryCount>
<ObjectEntryNameLength>10</ObjectEntryNameLength>
<Source>request</Source>
<StringValueLength>50</StringValueLength>
</JSONThreatProtection>
超過物件項目數量上限
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name]: Execution failed. reason: JSONThreatProtection[policy_name]: Exceeded object entry count at line line_num", "detail": { "errorcode": "steps.jsonthreatprotection.ExecutionFailed" } } }
錯誤回應主體範例
{
"fault": {
"faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
Exceeded object entry count at line 7",
"detail": {
"errorcode": "steps.jsonthreatprotection.ExecutionFailed"
}
}
}
原因
如果 <Source> 元素指定的輸入訊息酬載包含的 JSON 物件,其項目 (屬性) 數量超過政策 <ObjectEntryCount> 元素中指定的值,就會發生這個錯誤。
舉例來說,如果 <ObjectEntryCount> 元素為 5,但輸入的 JSON 酬載有超過 5 個項目,就會擲回這項錯誤。
診斷
查看錯誤訊息,找出 JSONThreatProtection 政策名稱,以及項目計數超出上限的行號。舉例來說,在下列錯誤訊息中,政策名稱為
JSON-Threat-Protection-1,酬載中的行號為7:JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded object entry count at line 7記下政策
<ObjectEntryCount>元素中指定的值 (在步驟 1 中找出)。在下列政策範例中,
<ObjectEntryCount>會設為5:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1"> <DisplayName>JSON Threat Protection-1</DisplayName> <Properties/> <ArrayElementCount>3</ArrayElementCount> <ContainerDepth>12</ContainerDepth> <ObjectEntryCount>5</ObjectEntryCount> <ObjectEntryNameLength>6</ObjectEntryNameLength> <Source>request</Source> <StringValueLength>50</StringValueLength> </JSONThreatProtection>檢查輸入酬載的特定行號 (步驟 1 中識別),並確認酬載中的實體數量是否大於為
<ObjectEntryCount>元素指定的值 (步驟 2 中識別)。如果物件數量超過物件項目計數,就是造成錯誤的原因。以下是輸入酬載範例:
{ "name" : "John", "id" : 234687, "age" : 31, "city" : "New York", "country" : "USA", "company" : "Google" }在上述 JSON 酬載中,第 6 個項目位於第 7 行 (公司)。由於輸入 JSON 酬載中的物件項目計數大於 5 (為
<ObjectEntryCount>元素指定的值),因此您會收到下列錯誤:JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded object entry count at line 7
解析度
如果 JSONThreatProtection 政策的目的是防範物件項目數量超過特定門檻的酬載,則會出現這則錯誤訊息。在這種情況下,你無須採取其他行動。
不過,如果您判斷可以在酬載中加入更多物件項目,且不會造成任何後果,請根據需求將 <ObjectEntryCount> 修改為適當的值。
舉例來說,如果您認為最多可允許 10 個物件項目,請按照下列方式修改 JSONThreatProtection 政策:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
<DisplayName>JSON Threat Protection-1</DisplayName>
<Properties/>
<ArrayElementCount>3</ArrayElementCount>
<ContainerDepth>12</ContainerDepth>
<ObjectEntryCount>10</ObjectEntryCount>
<ObjectEntryNameLength>6</ObjectEntryNameLength>
<Source>request</Source>
<StringValueLength>50</StringValueLength>
</JSONThreatProtection>
陣列元素數量超過上限
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name]: Execution failed. reason: JSONThreatProtection[policy_name]: Exceeded array element count at line line-num", "detail": { "errorcode": "steps.jsonthreatprotection.ExecutionFailed" } } }
錯誤回應主體範例
{
"fault": {
"faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
Exceeded array element count at line 3",
"detail": {
"errorcode": "steps.jsonthreatprotection.ExecutionFailed"
}
}
}
原因
如果 <Source> 元素指定的輸入訊息酬載包含的 JSON 陣列元素數量,超出政策 <ArrayElementCount> 元素中指定的數量,就會發生這個錯誤。
舉例來說,如果 <ArrayElementCount> 元素指定為 3,但輸入酬載的 JSON 陣列包含超過 3 個元素,就會擲回這項錯誤。
診斷
查看錯誤訊息,找出政策名稱和陣列長度超出上限的行號。舉例來說,在下列錯誤訊息中,政策名稱為
JSON-Threat-Protection-1,酬載中的行號為3:JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded array element count at line 3請記下政策
<ArrayElementCount>元素指定的值 (在步驟 1 中識別)。在下列 JSONThreatProtection 政策範例中,
<ArrayElementCount>會設為3:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1"> <DisplayName>JSON Threat Protection-1</DisplayName> <Properties/> <ArrayElementCount>3</ArrayElementCount> <ContainerDepth>12</ContainerDepth> <ObjectEntryCount>5</ObjectEntryCount> <ObjectEntryNameLength>6</ObjectEntryNameLength> <Source>request</Source> <StringValueLength>50</StringValueLength> </JSONThreatProtection>檢查輸入內容的特定行號 (在步驟 1 中識別),並確認該處指定的陣列計數是否高於
<ArrayElementCount>元素 (在步驟 2 中識別) 中指定的數字。如果陣列元素數量超過計數,就是造成錯誤的原因。以下是輸入酬載範例:
{ "name":"Ford", "models":[ "Mustang", "Endeavour", "Fiesta", "EcoSport", "Focus" ] }如上所示,JSON 酬載在第 3 行的
models陣列中包含 5 個元素。由於陣列元素數量大於 3 (為<ArrayElementCount>元素指定的值),因此您會收到下列錯誤:JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded array element count at line 3
解析度
如果 JSONThreatProtection 政策的目的是防範酬載超過特定陣列計數門檻,則會顯示這則錯誤訊息。在這種情況下,您不需要採取其他行動。
不過,如果您認為陣列中可允許的元素數量較多,請根據需求將 <ArrayElementCount> 修改為適當的值。
舉例來說,如果您認為最多可以允許 5 個陣列元素,請按照下列方式修改政策:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
<DisplayName>JSON Threat Protection-1</DisplayName>
<Properties/>
<ArrayElementCount>5</ArrayElementCount>
<ContainerDepth>12</ContainerDepth>
<ObjectEntryCount>5</ObjectEntryCount>
<ObjectEntryNameLength>6</ObjectEntryNameLength>
<Source>request</Source>
<StringValueLength>50</StringValueLength>
</JSONThreatProtection>
超過容器深度
錯誤回應主體
執行階段流量會傳回 500 回應碼,並顯示下列錯誤:
{ "fault": { "faultstring": "JSONThreatProtection[policy_name]: Execution failed. reason: JSONThreatProtection[policy_name]: Exceeded container depth at line line-num", "detail": { "errorcode": "steps.jsonthreatprotection.ExecutionFailed" } } }
錯誤回應主體範例
{
"fault": {
"faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
Exceeded container depth at line 5",
"detail": {
"errorcode": "steps.jsonthreatprotection.ExecutionFailed"
}
}
}
原因
如果 <Source> 元素指定的輸入訊息酬載包含 JSON 物件,而該物件的 JSON 元素容器深度超過政策 <ContainerDepth> 元素中指定的容器深度上限,就會發生這項錯誤。容器深度是 JSON 元素允許的巢狀深度上限。舉例來說,如果陣列包含物件,而該物件又包含物件,則包含深度為 3。
舉例來說,如果 <ContainerDepth> 元素是 3,但輸入內容的容器深度超過這個限制,就會擲回這個錯誤。
診斷
查看錯誤訊息,找出 JSONThreatProtection 政策名稱,以及容器深度超出限制的行號。舉例來說,在下列錯誤訊息中,政策名稱為
JSON-Threat-Protection-1,酬載中的行號為5。JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded container depth at line 5記下為
<ContainerDepth>元素指定的值 (在步驟 1 中識別)。在下列 JSONThreatProtection 政策範例中,
<ContainerDepth>會設為5:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1"> <DisplayName>JSON Threat Protection-1</DisplayName> <Properties/> <ArrayElementCount>3</ArrayElementCount> <ContainerDepth>5</ContainerDepth> <ObjectEntryCount>5</ObjectEntryCount> <ObjectEntryNameLength>20</ObjectEntryNameLength> <Source>request</Source> <StringValueLength>50</StringValueLength> </JSONThreatProtection>檢查輸入酬載的特定行號 (在步驟 1 中識別),並確認酬載中的容器深度是否高於
<ContainerDepth>元素中指定的值 (在步驟 2 中識別)。如果容器深度超過計數,就是造成錯誤的原因。以下是輸入酬載範例:
{ "ContainerDepth2":[ { "ContainerDepth4":[ { "ContainerDepth6":[ "1", "2" ] } ] } ] }如上所示,JSON 酬載在第 5 行的容器深度為 6。由於深度大於 5,因此您為 JSONThreatProtection 政策的
<ContainerDepth>元素指定的值會導致下列錯誤:JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded container depth at line 5
解析度
如果 JSONThreatProtection 政策的目的是防範容器深度超過指定值的酬載,則會出現這則錯誤訊息。在這種情況下,您不需要採取其他行動。
不過,如果您認為容器深度較高是可以接受的,請根據需求將 <ContainerDepth> 修改為適當的值。
舉例來說,如果您認為可以允許容器深度達 10,請按照下列方式修改政策:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
<DisplayName>JSON Threat Protection-1</DisplayName>
<Properties/>
<ArrayElementCount>3</ArrayElementCount>
<ContainerDepth>10</ContainerDepth>
<ObjectEntryCount>5</ObjectEntryCount>
<ObjectEntryNameLength>20</ObjectEntryNameLength>
<Source>request</Source>
<StringValueLength>50</StringValueLength>
</JSONThreatProtection>
字串值長度超出上限
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name]: Execution failed. reason: JSONThreatProtection[policy_name]: Exceeded string value length at line line-num", "detail": { "errorcode": "steps.jsonthreatprotection.ExecutionFailed" } } }
錯誤回應主體範例
{
"fault": {
"faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
Exceeded string value length at line 3",
"detail": {
"errorcode": "steps.jsonthreatprotection.ExecutionFailed"
}
}
}
原因
如果 <Source> 元素指定的輸入訊息酬載包含的 JSON 元素值,字元數超過 <StringValueLength> 元素允許的字元數,就會發生這個錯誤。
舉例來說,如果政策中的 <StringValueLength> 元素設為 50,但輸入的酬載有一或多個元素的值超過 50 個字元,就會擲回這項錯誤。
診斷
查看錯誤訊息,找出政策名稱和字串長度超出上限的行號。在以下範例中,酬載
3中的政策名稱為JSON-Threat-Protection-1 and。JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded string value length at line 3記下 (在步驟 1 中識別)
<StringValueLength>元素指定的值。在下列 JSONThreatProtection 政策範例中,
<StringValueLength>會設為50:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1"> <DisplayName>JSON Threat Protection-1</DisplayName> <Properties/> <ArrayElementCount>3</ArrayElementCount> <ContainerDepth>5</ContainerDepth> <ObjectEntryCount>5</ObjectEntryCount> <ObjectEntryNameLength>20</ObjectEntryNameLength> <Source>request</Source> <StringValueLength>50</StringValueLength> </JSONThreatProtection>檢查輸入內容的特定行號 (在步驟 1 中識別),並確認值的長度是否大於為
<StringValueLength>元素指定的字元數 (在步驟 2 中識別)。如果值長度超過上限,就是造成錯誤的原因。以下是輸入酬載範例:
{ "Country": "New Zealand", "Place Name": "Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu" }上方的 JSON 酬載有一個名為
Place Name的物件,其值Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu在第 3 行有 85 個字元。由於值長度超過 50,因此您在<StringValueLength>元素中指定的值會導致下列錯誤:JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded string value length at line 3
解析度
如果 JSONThreatProtection 政策的目的是防範值超過特定字串長度的酬載,則會出現錯誤訊息。在這種情況下,您不需要採取其他行動。
不過,如果您判斷可在酬載中指定較長的值長度,請根據需求將 <StringValueLength> 修改為適當的值。
舉例來說,如果您認為可以允許長度最多 90 的值,請按照下列方式修改政策:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
<DisplayName>JSON Threat Protection-1</DisplayName>
<Properties/>
<ArrayElementCount>3</ArrayElementCount>
<ContainerDepth>5</ContainerDepth>
<ObjectEntryCount>5</ObjectEntryCount>
<ObjectEntryNameLength>20</ObjectEntryNameLength>
<Source>request</Source>
<StringValueLength>90</StringValueLength>
</JSONThreatProtection>
不是有效的 JSON 物件
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name]: Execution failed. reason: string: at line line-num", "detail": { "errorcode": "steps.jsonthreatprotection.ExecutionFailed" } } }
錯誤回應主體範例
{
"fault": {
"faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
Execution failed. reason: Expecting : at line 3",
"detail": {
"errorcode": "steps.jsonthreatprotection.ExecutionFailed"
}
}
}
原因
如果 JSONThreatProtection 政策中 <Source> 元素指定的輸入訊息酬載不是有效的 JSON 物件,就會發生這個錯誤。
診斷
查看錯誤訊息,找出政策名稱和發生錯誤的行號。在以下範例中,酬載
2中的政策名稱為JSON-Threat-Protection-1 and。JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: Expecting : at line 3檢查輸入酬載的特定行號 (在步驟 1 中識別),並確認酬載中傳遞的 JSON 物件確實是有效的 JSON 物件。
以下是輸入酬載範例:
{ "Longitude": 6.11499, "Latitude" 50.76891 }在上述 JSON 酬載中,第 3 行沒有
":"(半形冒號)。由於這不是有效的 JSON 物件,因此會收到以下錯誤訊息:JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: Expecting : at line 3
解析度
請確保將有效的輸入 JSON 酬載傳遞至包含 JSONThreatProtection 政策的任何 API Proxy。
以上述範例為例,請按照下列方式修改 JSON 酬載:
{
"Longitude": 6.11499,
"Latitude" : 50.76891
}
SourceUnavailable
錯誤代碼
steps.jsonthreatprotection.SourceUnavailable
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name]:: Source[var_name] is not available" "detail": { "errorcode": "steps.jsonthreatprotection.SourceUnavailable" } } }
錯誤回應主體範例
{
"fault": {
"faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]::
Source requests is not available",
"detail": {
"errorcode": "steps.jsonthreatprotection.SourceUnavailable"
}
}
}
原因
如果 JSONThreatProtection 政策的 <Source> 元素中指定的 message 變數符合下列任一條件,就會發生這個錯誤:
- 超出範圍 (無法在執行政策的特定流程中使用)
- 不是有效值
request、response或message
舉例來說,如果政策中的 <Source> 元素設為變數,但該變數不存在於政策執行的流程中,就會發生這項錯誤。
診斷
從錯誤訊息中找出政策名稱和來源變數名稱。舉例來說,在下列錯誤訊息中,政策名稱為
JSON-Threat-Protection-1,來源變數為requests:JSONThreatProtection[JSON-Threat-Protection-1]:: Source requests is not available檢查步驟 1 中識別的
<Source>元素指定值。在下列 JSONThreatProtection 政策範例中,
<Source>元素會設為requests。<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1"> <DisplayName>JSON Threat Protection-1</DisplayName> <Properties/> <ArrayElementCount>3</ArrayElementCount> <ContainerDepth>5</ContainerDepth> <ObjectEntryCount>5</ObjectEntryCount> <ObjectEntryNameLength>20</ObjectEntryNameLength> <Source>requests</Source> <StringValueLength>50</StringValueLength> </JSONThreatProtection><Source>元素的有效值為request、response或message。因為「requests」不是有效值,且政策執行流程中沒有這個值,因此您會收到下列錯誤訊息:JSONThreatProtection[JSON-Threat-Protection-1]:: Source requests is not available
解析度
確認失敗的 JSONThreatProtection 政策 <Source> 元素中設定的變數設為 request、response 或 message,且存在於政策執行的流程中。
如要修正上述 JSONThreatProtection 政策範例,您可以修改 <Source> 元素,使用 request 變數,因為該變數存在於要求流程中:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
<DisplayName>JSON Threat Protection-1</DisplayName>
<Properties/>
<ArrayElementCount>3</ArrayElementCount>
<ContainerDepth>5</ContainerDepth>
<ObjectEntryCount>5</ObjectEntryCount>
<ObjectEntryNameLength>20</ObjectEntryNameLength>
<Source>request</Source>
<StringValueLength>50</StringValueLength>
</JSONThreatProtection>
NonMessageVariable
錯誤代碼
steps.jsonthreatprotection.NonMessageVariable
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name]: Variable var_name does not resolve to a Message" "detail": { "errorcode": "steps.jsonthreatprotection.NonMessageVariable" } } }
錯誤回應主體範例
{
"fault": {
"faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
Variable message.content does not resolve to a Message",
"detail": {
"errorcode": "steps.jsonthreatprotection.NonMessageVariable"
}
}
}
原因
如果 JSONThreatProtection 政策中的 <Source> 元素設為非 message 類型的變數,就會發生這個錯誤。
訊息型別變數代表整個 HTTP 要求和回應。內建的 Apigee 流程變數要求、回應和訊息屬於訊息類型。如要進一步瞭解訊息變數,請參閱變數參考資料。
診斷
從錯誤訊息中找出 JSONThreatProtection 政策名稱和來源變數名稱。舉例來說,在下列錯誤訊息中,政策名稱為
JSON-Threat-Protection-1,而來源變數為message.content:JSONThreatProtection[JSON-Threat-Protection-1]: Variable message.content does not resolve to a Message檢查 JSONThreatProtection 政策的
<Source>元素 (在步驟 1 中識別)。在下列 JSONThreatProtection 政策範例中,
<Source>會設為message.content,而不是message:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1"> <DisplayName>JSON Threat Protection-1</DisplayName> <Properties/> <ArrayElementCount>3</ArrayElementCount> <ContainerDepth>5</ContainerDepth> <ObjectEntryCount>5</ObjectEntryCount> <ObjectEntryNameLength>20</ObjectEntryNameLength> <Source>message.content</Source> <StringValueLength>50</StringValueLength> </JSONThreatProtection>由於
message.content不是訊息類型,因此您會收到以下錯誤訊息:JSONThreatProtection[JSON-Threat-Protection-1]: Variable message.content does not resolve to a Message
解析度
確認失敗的 JSONThreatProtection 政策中的 <Source> 元素已設為 message 類型流程變數,且該變數存在於政策執行的流程中。
如要修正政策,可以修改 <Source> 元素,指定訊息類型的變數。舉例來說,在失敗的 JSONThreatProtection 中,您可以將 <Source> 元素指定為 message:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
<DisplayName>JSON Threat Protection-1</DisplayName>
<Properties/>
<ArrayElementCount>3</ArrayElementCount>
<ContainerDepth>5</ContainerDepth>
<ObjectEntryCount>5</ObjectEntryCount>
<ObjectEntryNameLength>20</ObjectEntryNameLength>
<Source>message</Source>
<StringValueLength>50</StringValueLength>
</JSONThreatProtection>