Hello, I've been trying, and failing miserably, to convert a BLOB data type to and Base64 text string in order to send it through a web service.
Here's what I tried:
In both cases, I get this error:
I tried to set the length of the string to 2048(max value), and then it tried to assign 39,000 characters. I will appreciate any help I can get.
I'm working in BC14.
Did you try using the Base64 conversion functions in Codeunit 10 "Type Helper"?
There is both ConvertValueFromBase64 and ConvertValueToBase64.
In which line you are facing the issue, also you can avoid showing the message and direct your URL in here.
[/quote]The issue is in the codeunits where the data type conversion is happening.
This is a link to codeunit 4110 and 4111.
The error is thrown after the line Base64String := Convert.ToBase64String(InputArray).
This method uses the dotnet Convert subtype to run the conversion.
I hope this answers your question. The other linked codeunit uses a different implementation but still throws the exact same error.
In which line you are facing the issue, also you can avoid showing the message and direct your URL in here.
Okay Nitin Verma here you go:
OnRun()
GetEmployeeImage3('JR');
GetEmployeeImage3(EmployeeCode : Code[20]) : Text[2048]
Employees.GET(EmployeeCode);
IF NOT Employees.Image.HASVALUE THEN
EXIT;
TenantMedia.GET(Employees.Image.MEDIAID);
TenantMedia.CALCFIELDS(Content);
IF TenantMedia.Content.HASVALUE THEN BEGIN
CLEAR(PictureText);
CLEAR(PictureInStream);
TenantMedia.Content.CREATEINSTREAM(PictureInStream, (TEXTENCODING::UTF8));
//PictureText.ADDTEXT(Base64Convert.StreamToBase64String(PictureInStream));
//PicDataBASE64 := Base64Convert.StreamToBase64String(PictureInStream);
//PicDataBASE64 := Base64Convert1.ToBase64_6(PictureInStream);
PictureText.ADDTEXT(Base64Convert1.ToBase64_6(PictureInStream));
MESSAGE(PicDataBASE64);
END;
This is my codeunit where I tried using both resources referenced in my original post.
is it possible to share the code
I'm working in BC 14. I've updated my post accordingly.
Hi,
Are you trying to do in NAV or BC?
Thanks.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156