查看 Apigee Edge 說明文件。
前往
Apigee X說明文件。 資訊
EitherOptionOrFormat
錯誤訊息
透過 Edge UI 或 Edge Management 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&quo>t<; standalone="yes"? XMLToJSON async="false" continueOnError>=&quo<t;false&quo>t; enable<d="true>"<; name=&quo>t;XML<ToJSON" > Displ<ayNameXMLToJSON>/Disp<layNam>e Pr<opertie>s</ Outp>u
tVariableresponse/OutputVariable Sourceresponse/Source /XMLToJSON
解析度
請確認 XML 到 JSON 政策的 XML 包含政策中宣告的 <Options>
或 <Format>
元素。
範例 1:
<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
XMLToJSON async="false" continueOnError>=&quo<t;false&quo>t; enable<d="true>"<; name=&quo>t;XML<ToJSON>"<
Di>splay<NameXMLToJSON/>DisplayN<ame
Propert>ies/
< Fo>rmatgoog<le/Form>a<t
Outp>u
tVariableresponse/OutputVariable
Sourceresponse/Source
/XMLToJSON
範例 2:
<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
XMLToJSON async="false" continueOnError>=&quo<t;false&quo>t; enable<d="true>"<; name=&quo>t;XML<ToJSON&>quot;
< DisplayNameXML>ToJS<ON/DisplayName
> Proper<ties/
Option>s
< RecognizeNu>mbertrue/<RecognizeNumb>er
< Recogni>zeBoo<leantrue>/Reco<gnizeBoolean
> R<ecognizeNulltru>e/Rec<ognize>Null
< /Optio>n<s
Outp>u
tVariableresponse/OutputVariable
Sourceresponse/Source
/XMLToJSON
UnknownFormat
錯誤訊息
透過 Edge UI 或 Edge Management 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 Proxy 部署作業就會失敗。
預先定義的格式包括: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=&quo>t;t<rue" n>ame="<WithFormat&q>uot<; Display>Nam<eWithF>ormat/Disp<layName> <Properties/ >Formatgo<ogle.com/Format> <Output>Variable<respons>e</OutputVar>i
able Sourceresponse/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&quo>t<; standalone="yes"?
XMLToJSON async="false" continueOnError=>&qu<ot;false&qu>ot; enable<d="true>&qu<ot; name=&q>uot<;WithF>ormat&<quot;
> Di<splayNameWithF>ormat/Di<splayName
Pro>per<ties/
> Format<google/>F<ormat
Ou>t
putVariableresponse/OutputVariable
Sourceresponse/Source
/XMLToJSON