您正在查看 Apigee 和 Apigee Hybrid 說明文件。
    查看 
    Apigee Edge 說明文件。
EitherOptionOrFormat
錯誤訊息
透過 Apigee UI 或 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 UI 或 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>