Problem printing labels on my Zebra ZD420


I have developed a test application for printing labels.
Sometimes it prints like a charm, sometimes it doesn't print anything and
just throws exceptions like "Malformed Multipart Form Data" and "Malformed status response - unable to determine printer status".
Can you please help me with these errors?
I am using the latest Zebra.SDK nuget package (2.15.2634), Firmware version is V84.20.22Z.

Here is my sample code: