AnsweredAssumed Answered

Base64 Decode within a Groovy Script

Question asked by elisha.hersberg758558 on Feb 8, 2018
Latest reply on Feb 26, 2018 by sdecima

Hi,

 

I work on an integration between ServiceNow  and Salesforce.

I want to get Attachements from ServiceNow and send them to Salesforce.

 As described in this link: How to retrieve an attachment from service now ... | ServiceNow Community ,   ServiceNow store attachments zipped, splitted in multiple chucks and then encoded in Base64.

 

On ServiceNow I can query sys_attachment table and then I can query sys_attachment_doc table where sys_attachment = sys_id from the previous call.

 

The result is a list of sys_attachment_doc  records which have to be

  1. Base64 decoded
  2. combined in one document and send them to Salesforce.  
  3. Unzipped
  4. Send the result to SF

 

 

Currently I am able to get one document combined with all data but not decoded neither unzipped.

When I add the Base 64 Decode or the unzip step I get errors

 

 

 

When I remove the Base64 Decode step, the file is created in SF but it is corrupted.

When I leave the Base64 Decode step I get an error: 

 

Test execution of [SNOW->SF] Update Case From Incident completed with errors. Embedded message: Unable to store data, error copying stream.; Caused by: Failed generating xml document; Caused by: Invalid white space character (0x1b) in text to output

 

the error occured at the decoding step.

 

Any help will be appreciated.

Outcomes