I have an issue with the Base64 Encoding in ServiceNow?

srirampappagudi
Tera Expert

Hi Experts,

In Knowledge Management, I am trying to read the attachments. When I pull a dump in XML and try to decode the

attachments it works fine. But when I use the REST API and pull the attachments, I am not able to decode the file it

throws an error. When I try to compare the Base64 String in XML and REST API, both are different. Kindly let me know

how to get this issue resolved.

Thank you,

Sriram.

 

 

1 ACCEPTED SOLUTION

Hi Sriram,

Yes the actual data resides in sys_attachment_doc but not as whole but in chunks; so you won't get complete set of data from that table from single record.

https://snprotips.com/blog/2016/2/25/understanding-and-using-glideattachment

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

18 REPLIES 18

Hi Sriram,

Are you saying that from your local machine you want to pick up file and add that as an attachment to some ticket/record in ServiceNow?

Or you are fetching attachment from ServiceNow table record in java?

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

srirampappagudi
Tera Expert

Hi Ankur,

 

I am fetching/reading data from an Knowledge Article and trying to decrypt  the data. But the Base64 string in XML is different from the one in REST API. when I try to decrypt  it throws errors where as in XML it works fine.

 

Regards,

Sriram.

Hi Sriram,

So you are getting base64encoded data of attachment within ServiceNow

Are you trying to decode it within ServiceNow or java code?

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

srirampappagudi
Tera Expert

Hi Ankur,

 

I am trying to decode in Java and it does not work. But the Base64 data from the XML dump decodes and works fine.

 

Unable to understand whether I am missing any thing.

 

Regards,

Sriram.

Hi Sriram,

So you are saying you are not able to decode the base64encoded data and cannot create a file using java code?

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader