Getting error while converting data from JSON to XML

When we are trying to convert the JSON to XML using JSONToXML policy, we are getting the below error:

{
  "fault": {
      "faultstring": "JSONToXML[JSON-to-XML-StacaNomination]: Execution failed due to reason: JSONToXML[JSON-to-XML-StacaNomination]: Execution failed due to reason: null",
      "detail": {
      "errorcode": "steps.json2xml.ExecutionFailed"
  }
}

Here’s my JSONToXML policy

<JSONToXML async="false" continueOnError="false" enabled="true" name="JSON-to-XML-1">
    <DisplayName>JSON to XML 1</DisplayName>
    <Source>request</Source>
    <OutputVariable>response</OutputVariable>
    <Options>
        <NamespaceBlockName>#namespaces</NamespaceBlockName>
        <DefaultNamespaceNodeName>$default</DefaultNamespaceNodeName>
        <NamespaceSeparator>:</NamespaceSeparator>
        <AttributeBlockName>#attrs</AttributeBlockName>
        <AttributePrefix>@</AttributePrefix>
        <ObjectRootElementName>Root</ObjectRootElementName>
        <ArrayRootElementName>Array</ArrayRootElementName>
        <ArrayItemElementName>Item</ArrayItemElementName>
        <TextNodeName>#text</TextNodeName>
        <NullValue>NULL</NullValue>
        <InvalidCharsReplacement>_</InvalidCharsReplacement>
    </Options>
</JSONToXML>

Can someone please help find the cause of this issue ?

Solved Solved
0 1 1,464
1 ACCEPTED SOLUTION

1. Reviewed the API Proxy and found that the JSONToXML policy was defined in the Request flow

2. Since the "response" variable is undefined in the Request flow, we were getting the error

"Execution failed due to reason: null"

3. Modified the JSONToXML policy to use the OutputVariable as "request" and was able to get rid of the error.

View solution in original post

1 REPLY 1

1. Reviewed the API Proxy and found that the JSONToXML policy was defined in the Request flow

2. Since the "response" variable is undefined in the Request flow, we were getting the error

"Execution failed due to reason: null"

3. Modified the JSONToXML policy to use the OutputVariable as "request" and was able to get rid of the error.