JiminK80 Member since 2017 9 posts
Perficient Inc - New York
Posted: September 29, 2017
Last activity: October 4, 2017

Error while receiving a byte array from robotic automation

I'm trying to take a screenshot of the web search list (ex: 'keyboard' search on Amazon), convert the png file to byte array, and send the byte array over to pega application.

The following is the C# script I have for doing so:

if (string.IsNullOrEmpty(outputImagePath))


return null;


OpenSpan.Diagnostics.Diagnostic.TraceVerbose("Script", string.Format("Attempting to grab screen shot {0}/{1}/{2}/{3}", width, height, xCoordinate, yCoordinate));



Bitmap screenshot = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

Graphics screenGraph = Graphics.FromImage(screenshot);

screenGraph.CopyFromScreen(xCoordinate, yCoordinate, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);

screenshot.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Png);

ImageConverter converter = new ImageConverter();

return (byte[])converter.ConvertTo(screenshot, typeof(byte[]));


catch (Exception ex)


OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);

return null;


I'm trying to send the byte array to a Java Object property in Pega (ByteArray), but when I run the case to see if it got transferred, I get the attached error.

Any suggestions on how to fix this issue, or on the C# code is appreciated. Thanks.

Robotic Process Automation
Moderation Team has archived post
Share this page LinkedIn