iGlow / Blog / Content is not allowed in prolog

SAP CPI error

Content is not allowed in prolog in SAP CPI

Short answer: This error means an XML step in SAP CPI received a payload that does not start as XML. It usually happens when a call returned an HTML error page or JSON, or the body has stray characters before the first tag. To fix it, trace the payload and correct the step that produced it.

The problem

A mapping or XSLT step fails with "Content is not allowed in prolog" and you cannot see what it was fed. The payload in the log may look fine, because the trouble is a hidden byte or an HTML error page from an earlier call. You raise the log level to Trace, send again, open the trace and read through the steps to find where XML turned into something else.

What does Content is not allowed in prolog mean?

The prolog is everything before the first XML element, such as the optional XML declaration. The parser found text there that XML does not allow. SAP lists the message for a Cloud Integration flow with a message mapping step in KBA 3258051. The text 'occured' is spelled that way in the SAP message.

Full text in the log: com.sap.it.rt.adapter.http.api.exception.HttpResponseException: An internal server error occured: Content is not allowed in prolog

Why does it happen?

The most common cause comes first.

How do I fix Content is not allowed in prolog in SAP CPI?

  1. Set the iFlow log level to Trace and send the message again.
  2. Open the message trace and look at the payload going into the failing step.
  3. If it is HTML or JSON, fix the earlier step that produced it, or convert it to XML first.
  4. If it is XML with extra characters, remove them before the step. Resend.

How do I confirm it is fixed?

The payload at the failing step starts with <?xml or a root element, and the message completes.

Which adapter or step causes it?

Any step that parses XML: Message Mapping, XSLT, XML Validator, or an adapter with XML conversion. The payload may come from any earlier step.

Tips to avoid it next time

Check the status code of a receiver call before you use its answer. A router with a condition on the HTTP status can send failures to an error path instead of a mapping. Set the Accept header so the server returns XML. Remember that Trace log level shows payloads, so switch it off when you are done. This guide explains tracing.

See all ten in the 10 most common SAP CPI errors and how to fix each for SAP Cloud Integration (SAP Integration Suite).

The easy way: fix Content is not allowed in prolog with iGlow

iGlow is an AI agent for SAP Integration Suite and CPI that runs as a Chrome extension side panel. The hunt above is what the Fix button does for you.

  1. Open the panel. The failed message is listed with a Fix button.
  2. Click Fix. iGlow reads the error, the failing step and a short trace excerpt, and explains what entered the step and where it came from.
  3. If a script or XSLT is at fault, iGlow proposes a small change as a diff. You review and approve it, and iGlow takes a snapshot before it saves.
  4. If an earlier call returned an HTML page or JSON, iGlow explains which call and gives next steps. Fixing that call, for example its credentials, is up to you.
iGlow Fix answer for the demo iFlow Invoice_S4_to_Ariba: why the last message failed (a null amount, line 5 of mapInvoiceToCXML.groovy), the proposed fix marked rejected, and two options
What a Fix answer looks like: the cause, where the bad value came from, and options to choose from. This example is a different error, a null amount in a Groovy script.
The Fix flow, shown on another error (a null amount in a Groovy mapping script in the demo iFlow Invoice_S4_to_Ariba): click Fix, read the cause, review the patch. In the clip the patch is rejected, so nothing changes.

Nothing is saved or deployed without your click, and tenants tagged PRD are never changed. See the Fix failed messages guide. Add iGlow to Chrome.

Questions

What does Content is not allowed in prolog mean?

The XML parser found text before the XML starts. The payload is not XML, or has extra characters at the beginning.

How do I fix Content is not allowed in prolog in SAP CPI?

Trace the message, find the payload that enters the failing step, and fix the step that produced HTML, JSON or stray characters.

Which adapter or step causes Content is not allowed in prolog?

A step that parses XML, such as Message Mapping or XSLT. The bad payload usually comes from an earlier receiver call.

More from the blog and guides