Skip to Content
Author's profile photo Ritesh Kumar Kumaria

SAP Cloud Integration: Encoder – Base64: Conversion results in Line Feed character at every 76th position

Co-Author: Rajwinder Singh


Problem Statement – Encoder – Base64: Conversion results in Line Feed character at every 76th position


Example Process Flow to simulate the behavior:



1)     Following screenshot shows the Payload introduced via the first Content Modifier.



The payload consists of continuous text without any Line Feed.


2)     The following screenshot shows the Encoder settings to converts the text to Base64 format.



3)   After deploying the integration flow, the resultant text contains Base64 encoded output. However, there is also an additional line feed character present at every 76th position.



The reason for this behavior (as also highlighted in the WIKI pages below) is an old MIME format. Please refer the wiki page for more details.




Solution / Alternative:

Use groovy function encodeBase64() to convert to Base 64 which uses a more recent format and does not introduces a line feed character at every 76 position.



Output after Base64 conversion using groovy.



Sample Groovy:


import java.util.HashMap;


def Message processData(Message message) {



def body = message.getBody(String.class);


String encoded = body.bytes.encodeBase64().toString();



return message;



Please note: The purpose of the Blog is to share an alternative approach to the issue and does not suggest it as the only available alternative.


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Great stuff .. really helpful and interesting read..


      Author's profile photo Dheeraj Mahajan
      Dheeraj Mahajan

      could you pls also post the code for decoding?

      Author's profile photo Ritesh Kumar Kumaria
      Ritesh Kumar Kumaria
      Blog Post Author

      Hello Dheeraj,

      You could use the standard Decoder which should work fine, though I haven't tried it on this example. Alternatively method decodeBase64() could be used.



      Author's profile photo Piotr Radzki
      Piotr Radzki

      thanks a lot, I was actually fighting with this problem right now trying to convert body into a string and replace CRLF in a script 🙂 this one is much better approach 🙂

      Author's profile photo Jacques-Antoine Ollier
      Jacques-Antoine Ollier

      Excellent tip! Thank you Ritesh Kumar Kumaria !