您目前查看的是 Apigee 和 Apigee Hybrid 說明文件。
查看
Apigee Edge 說明文件。
EitherOptionOrFormat
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Saving Revision [revision_number] XMLToJSON[{0}]: Either Options or Format must be specified.
錯誤範例
Error Saving Revision 1
XMLToJSON[{0}]: Either Options or Format must be specified.
螢幕截圖範例

原因
如果 XML 轉 JSON 政策中未宣告 <Options> 或 <Format> 元素,API Proxy 的部署作業就會失敗。
如未使用 <Format>,則必須提供 <Options>。
使用 <Format> 元素或 <Options> 元素群組。您無法同時使用 <Format> 和 <Options>。預先定義的格式包括:xml.com、yahoo、google 和 badgerFish。
診斷
檢查發生失敗的特定 API Proxy 中的所有 XML 轉 JSON 政策。如果 XML 轉 JSON 政策中未宣告
<Options>或<Format>元素,就會導致錯誤。舉例來說,下列政策未宣告任一元素:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <XMLToJSON async="false" continueOnError="false" enabled="true" name="XMLToJSON"> <DisplayName>XMLToJSON</DisplayName> <Properties/> <OutputVariable>response</OutputVariable> <Source>response</Source> </XMLToJSON>
解析度
確認 XML 轉 JSON 政策的 XML 含有政策中宣告的 <Options> 或 <Format> 元素。
範例 1:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XMLToJSON async="false" continueOnError="false" enabled="true" name="XMLToJSON">
<DisplayName>XMLToJSON</DisplayName>
<Properties/>
<Format>google</Format>
<OutputVariable>response</OutputVariable>
<Source>response</Source>
</XMLToJSON>
範例 2:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XMLToJSON async="false" continueOnError="false" enabled="true" name="XMLToJSON">
<DisplayName>XMLToJSON</DisplayName>
<Properties/>
<Options>
<RecognizeNumber>true</RecognizeNumber>
<RecognizeBoolean>true</RecognizeBoolean>
<RecognizeNull>true</RecognizeNull>
</Options>
<OutputVariable>response</OutputVariable>
<Source>response</Source>
</XMLToJSON>
UnknownFormat
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Saving Revision [revision_number] XMLToJSON[policy_name]: Unknown Format [unknown_format].
錯誤範例
Error Saving Revision 1
XMLToJSON[WithFormat]: Unknown Format google.com.
螢幕截圖範例

原因
如果 XML 轉 JSON 政策中的 <Format> 元素定義了不明格式,API 代理項目部署作業就會失敗。
預先定義的格式包括:xml.com、yahoo、google 和 badgerFish。
診斷
找出發生錯誤和不明格式的 XML 轉 JSON 政策。這項資訊會顯示在錯誤訊息中。舉例來說,在下列錯誤中,政策名稱為
WithFormat,不明格式為google.com:Error Saving Revision 1 XMLToJSON[WithFormat]: Unknown Format google.com.確認失敗的 XML 轉 JSON 政策中指定的不明格式,與上述步驟 1 的錯誤訊息中識別的值相符。舉例來說,下列政策將格式指定為
google.com,與錯誤訊息中的格式相符:<XMLToJSON async="false" continueOnError="false" enabled="true" name="WithFormat"> <DisplayName>WithFormat</DisplayName> <Properties/> <Format>google.com</Format> <OutputVariable>response</OutputVariable> <Source>response</Source> </XMLToJSON>如果指定的格式不是預先定義的
xml.com、yahoo、google或badgerFish格式,就會導致錯誤。在上述 XML 轉 JSON 政策範例中,格式為
google.com,這是無效格式。因此,API Proxy 部署作業會失敗,並顯示下列錯誤:XMLToJSON[WithFormat]: Unknown Format google.com.
解析度
請確認 XML 轉 JSON 政策的 <Format> 元素中指定的格式有效。例如:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XMLToJSON async="false" continueOnError="false" enabled="true" name="WithFormat">
<DisplayName>WithFormat</DisplayName>
<Properties/>
<Format>google</Format>
<OutputVariable>response</OutputVariable>
<Source>response</Source>
</XMLToJSON>