on 2024 Oct 08 8:14 PM
Hi Experts,
I have a requirement where I am fetching a file(can be of .pdf/.xls/.word/.txt any format) from Azure DevOps portal and want to send that attachment file in base 64 format to Service Now.
The file fetched from Azure is coming in CPI in binary format(other than .txt file) and it is not readable format. The target system is only excepting base 64 encoded file.
Please guide me how can I convert the binary file getting downloaded in readable format?
Thanks,
Nidhi Srivastava
Hi ,Maybe you can try this
import com.sap.gateway.ip.core.customdev.util.Message
import java.util.Base64
def Message processData(Message message) {
// Get the binary file content from the message body
byte[] binaryContent = message.getBody(byte[].class)
// Convert the binary content to Base64
String base64Content = Base64.getEncoder().encodeToString(binaryContent)
// Set the Base64 encoded content as the message body
message.setBody(base64Content)
// Set the file name in the message headers
def headers = message.getHeaders()
headers.put("FileName", "your_file_name_here.pdf") // Replace with the actual file name
return message
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
10 | |
10 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.