Closed ewan-derivco closed 2 years ago
Uri.EscapeDataString fails if the string is longer than 32k characters (depending on framework?)
This causes an exception to be thrown in Splunk.Client.Context.CreateStringContent while the API can accept the long value.
Fix by splitting the string and looping?
/// <summary> /// deal with long searches /// </summary> /// <param name="data"></param> /// <returns></returns> private static string EscapeDataString(string value) { int limit = 20000; StringBuilder sb = new StringBuilder(); int loops = value.Length / limit; for (int i = 0; i <= loops; i++) { if (i < loops) { sb.Append(Uri.EscapeDataString(value.Substring(limit * i, limit))); } else { sb.Append(Uri.EscapeDataString(value.Substring(limit * i))); } } return sb.ToString(); }
https://docs.microsoft.com/en-us/dotnet/api/system.uri.escapedatastring?view=netframework-4.8
This SDK is deprecated and no longer under active development.
Uri.EscapeDataString fails if the string is longer than 32k characters (depending on framework?)
This causes an exception to be thrown in Splunk.Client.Context.CreateStringContent while the API can accept the long value.
Fix by splitting the string and looping?
https://docs.microsoft.com/en-us/dotnet/api/system.uri.escapedatastring?view=netframework-4.8