I got an error when trying to convert json to xml
error is :
{ "fault": { "faultstring": "JSONToXML[JSON-to-XML-3]: Source response is not available", "detail": { "errorcode": "steps.json2xml.SourceUnavailable" } } }
and this the policy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <JSONToXML async="false" continueOnError="false" enabled="true" name="JSON-to-XML-3"> <DisplayName>JSON to XML-3</DisplayName> <Properties/> <Options> <NullValue>NULL</NullValue> <NamespaceBlockName>#namespaces</NamespaceBlockName> <DefaultNamespaceNodeName>$default</DefaultNamespaceNodeName> <NamespaceSeparator>:</NamespaceSeparator> <TextNodeName>#text</TextNodeName> <AttributeBlockName>#attrs</AttributeBlockName> <AttributePrefix>@</AttributePrefix> <InvalidCharsReplacement>_</InvalidCharsReplacement> <ObjectRootElementName>Root</ObjectRootElementName> <ArrayRootElementName>Array</ArrayRootElementName> <ArrayItemElementName>Item</ArrayItemElementName> </Options> <OutputVariable>request</OutputVariable> <Source>response</Source> </JSONToXML>
Solved! Go to Solution.
Hi @Omar Elsaid. Welcome to the Apigee community.
Based on the error encountered by you it seems that you have attached the policy at some point before the proxy receives the response from the target. Could you please share a screenshot of the trace? If not, please mention in which specific flow you have attached the above policy.
If this is indeed a case of incorrect placement of the policy then you can easily rectify it by moving your policy to the Response flow in the TargetEndpoint.