1

I'm trying to post simple request using Flurl. But there is an exception, because takenPicture string is too large. Is there any way to post large string using Flurl?

System.UriFormatException: Uri is longer than the maximum 32766 characters.

var postData = BaseAdress.PostUrlEncodedAsync(new {
   text = Uri.EscapeDataString(body),
   subject = Uri.EscapeDataString(subject),
   from_email = from,
   recipient_email = to,
   picture = takenPicture //Base64 string
});
anoop
  • 2,893
  • 19
  • 33

1 Answers1

1

This limitation, while a little arbitrary, is by design in Microsoft's Uri.EscapeDataString method, which is commonly used by applications and libraries (including Flurl) to encode data for both URL queries and URL-encoded request bodies. Both Xamarin and RestSharp Portable have dealt with this so I'm sure a work-around is possible and I might consider this in Flurl if you want to create an issue.

However, keep in mind that URL-encoding binary data like images is very unusual, and there are good reasons to avoid it if possible. Of course, if this is a 3rd-party API you're working with, you don't have much of a choice. But if you have control of the server-side code, I would suggest refactoring that to accept multipart/form-data instead.

Community
  • 1
  • 1
Todd Menier
  • 32,399
  • 14
  • 130
  • 153