{"fault":{"faultstring":"XMLToJSON[policy_name]: Source [source_variable] is not available","detail":{"errorcode":"steps.xmltojson.SourceUnavailable"}}}
Example Error Message
{ "fault": { "faultstring": "XMLToJSON[Convert-XMLToJSON]: Source response is not available", "detail": { "errorcode": "steps.xml2json.SourceUnavailable" } }}
Cause
This error occurs if the message or string variable specified in the element of the XML to JSON policy is either:
out of scope (not available in the specific flow where the policy is being executed) or
can't be resolved (is not defined)
For example, this error occurs if the XML to JSON policy is supposed to be executed in the request flow, but the element is set to the response variable, which doesn't exist in the request flow.
Diagnosis
Identify the XML to JSON policy where the error occurred and the name of the variable that is not available. You can find both of these items in the faultstring element of the error response. For example, in the following faultstring, the policy name is Convert-XMLToJSON and the variable is response:
"faultstring": "XMLToJSON[Convert-XMLToJSON]: Source response is not available"
In the failed XML to JSON policy XML, verify that the name of the variable set in the element matches the variable name identified in the fault string (step #1 above). For example, the following XML to JSON policy specifies a variable named response in the element, which matches what's in the faultstring:
Convert-XMLToJSONgoogleresponseresponse
Determine if the variable used in the element is defined and available in the flow in which the XML to JSON policy is being executed.
If the variable is either:
out of scope (not available in the specific flow where the policy is being executed) or
can't be resolved (is not defined)
then that's the cause for the error.
As an example, let's say the XML to JSON policy shown above is supposed to be executed in the request flow. Recall that the response variable is used in the element of the XML to JSON policy. The response variable is available only in the response flow.
Because the response variable does not exist in the request flow, you receive the error code:
steps.xml2json.SourceUnavailable
Resolution
Ensure that the variable set in the element of the failed XML to JSON policy, is defined and exists in the flow where the policy executes.
To correct the example XML to JSON policy shown above, you could modify the element to use the request variable as it exists in the request flow:
Convert-XMLToJSONgoogleresponserequest
ExecutionFailed
Error code
steps.xml2json.ExecutionFailed
Error response body
{"fault":{"faultstring":"XMLToJSON[policy_name]: Execution failed. reason: Premature end of document while parsing at line [line_number](possibly around char [character_number])","detail":{"errorcode":"steps.xml2json.ExecutionFailed"}}}
The input (XML) passed to XML to JSON policy is invalid or malformed.
Cause: Missing input payload
In the XML to JSON policy if the content (payload) of the variable specified in the element is empty, then this error occurs.
For example, if the element in the XML to JSON policy is set as a request or response variable and it is supposed to contain an XML payload, this error occurs if the payload is empty.
Diagnosis
Identify the XML to JSON policy where the error occurred. You can find this information in the faultstring element of the error response. For example, in the following faultstring, the policy name is Convert-XMLToJSON:
"faultstring": "XMLToJSON[Convert-XMLToJSON]: Execution failed. reason: Premature end of document while parsing at line 1(possibly around char 0)"
Examine the element in the failing XML to JSON policy XML and determine the variable specified. For example, the following XML to JSON policy has element set to request:
Convert-XMLToJSONtruetruetruerequestrequest
Check if the variable specified for the element in the XMLToJSON policy is empty. If it is empty, then that's the cause for the error.
In the example XML to JSON policy shown above, the request payload (i.e, request body) that was sent by the client was empty.
Where your_host_alias is a publicly facing domain used to access your APIs,
as configured in the virtualhosts.hostAliases property in your overrides file.
See Specify configuration
overrides.
Because the XML request payload is empty, you receive the error code:
steps.xml2json.ExecutionFailed
This error can also occur if the element is set to response, but an empty payload is passed by the backend server.
Resolution
Ensure that the input passed to XML to JSON policy via the element is a valid XML payload and non-empty.
To fix the issue with the sample XML to JSON policy, pass a valid XML payload. For example:
Create a file named city.xml with the following contents:
BengaluruApigee560016
Make the API call using a cURL command as follows:
curl -v "http://your_host_alias/v1/testxmltojson" -H "Content-Type: application/xml" -X POST -d @company.xml
Where your_host_alias is a publicly facing domain used to access your APIs,
as configured in the virtualhosts.hostAliases property in your overrides file.
See Specify configuration
overrides.
Cause: Invalid or Malformed Input
If the XML to JSON policy parses input that is invalid or malformed, then you get this error.
For example, if the following invalid XML is provided as input to the XML to JSON policy,
BengaluruApigee560016
you will get the error:
"faultstring": "XMLToJSON[Convert-XMLToJSON]: Execution failed. reason: Premature end of document while parsing at line 6(possibly around char 0)"
Diagnosis
Identify the XML to JSON policy where the error occurred. You can find this information in the faultstring element of the error response. For example, in the following faultstring, the policy name is Convert-XMLToJSON:
"faultstring": "XMLToJSON[Convert-XMLToJSON]: Execution failed. reason: Premature end of document while parsing at line 6(possibly around char 0)"
Examine the element specified in the failing XML to JSON policy XML. For example, the following XML to JSON policy has the element set to the request variable:
Convert-XMLToJSONtruetruetruerequestrequest
Validate if the input specified in the element to the XML To JSON policy is a valid XML payload. If the input is invalid or malformed, then that's the cause for the error.
In the example XML to JSON policy shown above, the following invalid XML was passed to Extract Variables policy via the file city.xml:
BengaluruApigee560016
Here's the sample API call that shows how the request was passed:
curl -v "http://your_host_alias/v1/testxmltpjson" -H "Content-Type: application/xml" -X POST -d @city.xml
Where your_host_alias is a publicly facing domain used to access your APIs,
as configured in the virtualhosts.hostAliases property in your overrides file.
See Specify configuration
overrides.
The XML payload passed to the API is invalid, as the XML does not have an end tag for element. So you receive the error code:
steps.xml2json.ExecutionFailed
This error can also occur if the element was set to response but the XML response payload from the backend server is invalid or malformed.
Resolution
Ensure that the input passed to XML to JSON policy via the element is valid and not malformed.
To fix the issue with the sample XML to JSON policy discussed above, pass a valid XML payload request as follows:
BengaluruApigee560016
OutputVariableIsNotAvailable
Error code
steps.xml2json.OutputVariableIsNotAvailable
Error response body
{"fault":{"faultstring":"XMLToJSON[policy_name]: Output variable is not available.","detail":{"errorcode":"steps.xml2json.OutputVariableIsNotAvailable"}}}
Example Error Message
{"fault":{"faultstring":"XMLToJSON[Convert-XMLToJSON]: Output variable is not available.","detail":{"errorcode":"steps.xml2json.OutputVariableIsNotAvailable"}}}
Cause
This error occurs if the variable specified in the element of the XML to JSON policy is of type string and the element is not defined. The element is mandatory when the variable defined in the element is of type string.
Diagnosis
Identify the XML to JSON Policy where the error has occurred. You can find this in the faultstring element of the error response. For example, in the following faultstring, the policy name is Convert-XMLToJSON:
"faultstring":"XMLToJSON[Convert-XMLToJSON]: Output variable is not available."
In the failed XML to JSON Policy validate if the is missing.
Here's a sample XML to JSON Policy that has missing element.
Convert-XMLToJSONgoogleTrackingNumber
Determine the type of variable specified in the element:
Locate the code within the API Proxy bundle, where the variable was defined first.
Once you figure out the policy in which the variable is defined and populated first, you need to determine the type of that variable as follows:
Check the value of the type attribute (if present).
If the type attribute is not present, then the variable is considered to be a string.
If the variable's type is string, then that's the cause of the error. You can learn about common variables and their types in the Variables reference.
For example, look at the TrackingNumber variable in the above XML to JSON policy. It is of type string. Now, consider an Assign Message policy that is used to set value to a variable called TrackingNumber as shown below:
Note that the variable type set via is string. So the variable TrackingNumber is of type string.
Now, recall that the TrackingNumber variable is used in the element of the XML To JSON policy:
TrackingNumber
Since TrackingNumber is of string type and the is missing in the policy, you receive the error code:
steps.xml2json.OutputVariableIsNotAvailable
Resolution
Ensure that if the variable specified in the element of the XMLToJSON Policy is of type string, the element is mandatory in this case.
To correct the XML To JSON Policy discussed above, include the element as shown below.
Convert-XMLToJSONgoogleresponseTrackingNumber
InCompatibleTypes
Error code
steps.xml2json.InCompatibleTypes
Error response body
{"fault":{"faultstring":"XMLToJSON[policy_name]: String can not be assigned to message type.","detail":{"errorcode":"steps.xml2json.InCompatibleTypes"}}}
Example Error Message
{"fault":{"faultstring":"XMLToJSON[XMLToJSON_CheckType]: String can not be assigned to message type.","detail":{"errorcode":"steps.xml2json.InCompatibleTypes"}}}
Cause
This error occurs if the type of the variable defined in the element and the element are not the same. It is mandatory that the type of the variables contained within the element and the element matches.
Thevalidtypesaremessageandstring.
Diagnosis
Identify the XML to JSON Policy where the error has occurred. You can find this in the faultstring element of the error response. For example, in the following faultstring, the policy name is XMLToJSON_CheckType:
"faultstring":"XMLToJSON[XMLToJSON_CheckType]: String can not be assigned to message type."
In the failed XML To JSON Policy note the values specified in .
Here's a sample XMLToJSON policy that has missing element
XMLToJSON_CheckTypegooglerequestTrackingNumber
Determine the type of variable specified in and elements:
Locate the code within the API Proxy bundle, where each of these variables were defined first.
Once you figure out the policy in which the variable is defined and populated first, you need to determine the type of that variable as follows:
Check the value of the type attribute (if present).
If the type attribute is not present, then the variable is considered to be a string.
If the type of the variable specified in is string while the type of is message or vice versa, then that's the cause of the error. You can learn about common variables and their types in the Variables reference.
As an example, consider an Assign Message policy that is used to set a value to a variable called TrackingNumber as shown below:
Note that the variable type set via is string. So the variable TrackingNumber is of type string.
Now, recall that the TrackingNumber variable is used in the element of the XMLToJSON policy:
TrackingNumber
Similarly, recall that the request variable is used in the element of the XML To JSON policy:
request
Because TrackingNumber is of type string while the response variable is of type message, they are incompatible types so you receive the error code:
steps.xml2json.InCompatibleTypes
The above error can also occur if the variable in the element is of type message but the variable in the element is of type string.
Resolution
Ensure that the type of the variable defined in the element and the element are always the same. It is mandatory that the type of the variables contained within the element and the element matches.
To correct the XML To JSON Policy discussed above, you could declare another variable TrackingNumber_output of type string using the Assign Message Policy and use this variable in the element of the XML To JSON Policy.
{"fault":{"faultstring":"XMLToJSON[class invalid_class]: Invalid source type class invalid_class. Valid source types are [message, string].","detail":{"errorcode":"steps.xml2json.InvalidSourceType"}}}
Example Error Message
{"fault":{"faultstring":"XMLToJSON[class java.lang.Integer]: Invalid source type class java.lang.Integer. Valid source types are [message, string].","detail":{"errorcode":"steps.xml2json.InvalidSourceType"}}}
Cause
This error occurs if the type of the variable used to define the element is invalid.The valid types of variable are message and string.
Diagnosis
Identify the invalid source type used in the XML to JSON policy. You can find this information from the error message. For example, in the following error, the invalid type is integer.
"faultstring":"XMLToJSON[class java.lang.Integer]: Invalid source type class java.lang.Integer. Valid source types are [message, string]."
Examine all the XML to JSON policies in the specific API Proxy where the failure has occurred. In the failed XML To JSON Policy note the name of the variable specified in .
XMLToJSON_CheckTypegoogleresponseBookCode
Determine the type of variable specified in element:
Locate the code within the API Proxy bundle, where this variable was defined first.
Once you figure out the policy in which the variable is defined and populated first, you need to determine the type of that variable as follows:
Check the value of the type attribute (if present).
If the type attribute is not present, then the variable is considered to be a string.
If the type of the variable specified in is neither message nor string type, then that's the cause of the error. You can learn about common variables and their types in the Variables reference.
As an example, consider an ExtractVariables policy that is used to extract the value from an XML payload and sets the value to the variable BookCode to be integer type as shown below:
Now, recall that the BookCode variable is used in the element of the XML To JSON policy:
BookCode
Because the type of this variable is Integer, which is not a valid type, the API Proxy fails with the error:
steps.xml2json.InvalidSourceType
Resolution
Ensure that the type of the variable used to specify the element is valid. The valid types are message and string.
To avoid the above error with XML To JSON policy, you could use the request variable which is of type message or any other string which is a valid XML payload.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-12 UTC."],[[["The `steps.xml2json.SourceUnavailable` error occurs when the variable specified in the `\u003cSource\u003e` element of the XML to JSON policy is either out of scope or undefined in the current flow."],["The `steps.xml2json.ExecutionFailed` error can occur if the input XML payload is missing or is malformed, so you must ensure the `\u003cSource\u003e` element references valid and non-empty XML content."],["The `steps.xml2json.OutputVariableIsNotAvailable` error happens when the `\u003cOutputVariable\u003e` element is not defined in the policy, even though the `\u003cSource\u003e` element is a string, which requires that the `\u003cOutputVariable\u003e` element be defined."],["The error `steps.xml2json.InCompatibleTypes` arises when the variable type in the `\u003cSource\u003e` element does not match the variable type in the `\u003cOutputVariable\u003e` element, as they must be of the same type (either `message` or `string`)."],["The `steps.xml2json.InvalidSourceType` error arises when the type of the variable set in the `\u003cSource\u003e` element is an invalid type, where the only valid types are `message` and `string`."]]],[]]