Flurl: URI too long error

When calling PostUrlEncodedAsync I’m receiving an error when the code tries to URL encode a large string (300kb).

      Invalid URI: The Uri string is too long.
System.UriFormatException: Invalid URI: The Uri string is too long.
   at System.UriHelper.EscapeString(String input, Int32 start, Int32 end, Char[] dest, Int32& destPos, Boolean isUriString, Char force1, Char force2, Char rsvd)
   at System.Uri.EscapeDataString(String stringToEscape)
   at Flurl.Url.EncodeQueryParamValue(Object value, Boolean encodeSpaceAsPlus) in C:\projects\flurl\src\Flurl.Shared\Url.cs:line 139
   at Flurl.Http.Configuration.DefaultUrlEncodedSerializer.Serialize(Object obj) in C:\projects\flurl\src\Flurl.Http.Shared\Configuration\DefaultUrlEncodedSerializer.cs:line 26
   at Flurl.Http.HttpExtensions.PostUrlEncodedAsync(IFlurlClient client, Object data, CancellationToken cancellationToken, HttpCompletionOption completionOption) in C:\projects\flurl\src\Flurl.Http.Shared\HttpExtensions.cs:line 513

The api we are calling is proprietary and does not accept POSTing application/json content. It only accepts a application/x-www-form-urlencoded payload.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

This is back on my radar and I’ll try to get it fixed for the next maintenance release. The best way to deal with this might be to just add a net45 specific target to Flurl so that .NET 4.5+ takes the “else” path here.

No need for a repro, https://github.com/dotnet/corefx/issues/1936 explains the issue perfectly well.