Hello,
We are trying to integrate with a client's external system to send notifications and, when we send documents attached to the notification, they arrive corrupted.
As I mentioned, to send the notifications we need to call an external system and the request body has 3 parameters. One of them must be in base64, which originally is an XML that contains the notification information (body, recipients, attachments, etc.).
The XML code is the follow one:
concat( "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>", "<solicitudUnicoType xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:sms=""SMSBus"" xmlns:email=""email"" xmlns:push=""push"">", "<solicitud><envioObligado>", /*(Opcional) Indicar si se debe realizar la comunicación solamente por una vía de envío: SMS, EMAIL, PUSH sin contingencias*/ "EMAIL", "</envioObligado>", "<email><email:solicitudEmail><email:codigoPeticion>", ri!codigoPeticion, "</email:codigoPeticion><email:destinatarios emailUnico=""", cons!ARQ_GNM_VALOR_EMAIL_UNICO, """>", /*Destinatarios*/ joinarray( a!forEach( items: ri!arrayDestinatarios, expression: char(10) & "<email:destinatario>" & fv!item & "</email:destinatario>" ), "" ), "</email:destinatarios><email:plantilla codigo=""", cons!ARQ_GNM_VALOR_CODIGO_PLANTILLA, """></email:plantilla><email:asunto>", ri!asunto, "</email:asunto><email:cuerpo>", toHtml(ri!cuerpo), "</email:cuerpo>", if( a!isNullOrEmpty(ri!adjuntos), null, concat( "<email:adjuntos>", a!forEach( items: ri!adjuntos, expression: concat( "<email:adjunto id=""idEjemplo"" nombre=""", document(fv!item, "name") & "." & document(fv!item, "extension"), """ extension=""pdf"">", fv!item, "</email:adjunto>" ) ), "</email:adjuntos>" ) ), "</email:solicitudEmail></email>", "</solicitud></solicitudUnicoType>" )
At first, to generate the body of the request I used the "encodebase64string" function (plugin), as can be seen in the following code fragment, but this function corrupts the file.
{ source: cons!ARQ_GNM_VALOR_SOURCE_APP, destination: cons!ARQ_GNM_VALOR_DESTINATION_APP, notificationData: encodebase64string( concat( "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>", "<solicitudUnicoType xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:sms=""SMSBus"" xmlns:email=""email"" xmlns:push=""push"">", "<solicitud><envioObligado>", /*(Opcional) Indicar si se debe realizar la comunicación solamente por una vía de envío: SMS, EMAIL, PUSH sin contingencias*/ "EMAIL", "</envioObligado>", "<email><email:solicitudEmail><email:codigoPeticion>", ri!codigoPeticion, "</email:codigoPeticion><email:destinatarios emailUnico=""", cons!ARQ_GNM_VALOR_EMAIL_UNICO, """>", /*Destinatarios*/ joinarray( a!forEach( items: ri!arrayDestinatarios, expression: char(10) & "<email:destinatario>" & fv!item & "</email:destinatario>" ), "" ), "</email:destinatarios><email:plantilla codigo=""", cons!ARQ_GNM_VALOR_CODIGO_PLANTILLA, """></email:plantilla><email:asunto>", ri!asunto, "</email:asunto><email:cuerpo>", toHtml(ri!cuerpo), "</email:cuerpo>", if( a!isNullOrEmpty(ri!adjuntos), null, concat( "<email:adjuntos>", a!forEach( items: ri!adjuntos, expression: concat( "<email:adjunto id=""idEjemplo"" nombre=""", document(fv!item, "name") & "." & document(fv!item, "extension"), """ extension=""pdf"">", fv!item, "</email:adjunto>" ) ), "</email:adjuntos>" ) ), "</email:solicitudEmail></email>", "</solicitud></solicitudUnicoType>" ) ) }
Then I tried to generate the XML as a document and pass it as a rule input. The code to generate the XML is the same.
This last solution also continues sending the corrupt attachment. Because when generating the XML text and then passing it to a document, the attachment is corrupted.
I can't think of any other solution to try. Could you help me?
Thanks.
Discussion posts and replies are publicly visible
It seems like you're encountering issues with encoding the XML document containing attachments into Base64 for transmission via an external system.