As discussed in last article we will Test customization using API that we developed this week for integration from #msdyn365bc or #MSDynNAV.
Transferring data from Business Central Tables through API is one of the latest version of transferring data from or to Business Central using the API Page Objects or Web Services.
Well, it gets a little difficult to transfer file blobs using the Media.ReadLinks and Media.EditLinks JSON field.
This Codeunit is my take on handling Base64 encoded-information in payloads of Webservices. The goal of the Codeunit is to be able to identify a Base64-string inside a variable which content is unknown and to store the content in a BLOB-field.
Bron : Hannes Holst
A couple of weeks ago, I was trying to write web service examples in AL code for VS Code. Unfortunately, at that time, it was not possible to call the Base64 methods on the TempBLOB table. And because those functions on the TempBLOB table are using .Net, I figured it was going to take a while before we get Base64 support in AL code. So I decided to write Base64 encoding / decoding routines myself. Just as an excercise and at that moment I didn’t know if I would even succeed.
With this code you can decode a BigText variable with a Base64 coded string (in this case a PDF document)….
- abpBigPDFText -> BigText
- abpAutConvertBase64 -> DotNet ‘mscorlib, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Convert
- abpAutBytes -> DotNet ‘mscorlib, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Array
- abpAutMemoryStream -> DotNet ‘mscorlib, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.IO.MemoryStream
- abpOutStream -> OutStream
- abpRecTempBlob -> Record TempBlob