SOLVED

How to test URI query string length?

Go to solution
Mike_Dinnis
Level 1

How to test URI query string length?

In various places within the developer documentation (error-codes, REST API exception and error handling) we are advised:

414 will be returned when the URI of a GET request exceeds 8KB.  To avoid it, check against the length of your query string to see if it exceeds this limit.

How do I check the length of a URI GET request query string in C# to avoid a 414 error?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: How to test URI query string length?

Umm String.Length?

Of course you can wrap this in a method of a class that extends your HTTP library (whatever that is) as .ensureMaxLength() or whatever.

Not really a Marketo question.

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: How to test URI query string length?

Umm String.Length?

Of course you can wrap this in a method of a class that extends your HTTP library (whatever that is) as .ensureMaxLength() or whatever.

Not really a Marketo question.

Mike_Dinnis
Level 1

Re: How to test URI query string length?

String.Length will return the number of characters in a string and not the size e.g. 8KB. Am I missing something here?

I agree that this isn't really a Marketo question, but since it's advocated as best practice in a few places I thought someone would know the best way to do this.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to test URI query string length?

 A URL-encoded String is ASCII. Every internal char in the string becomes 1 byte wide on the wire, e.g. %20 is 3 bytes. 

Mike_Dinnis
Level 1

Re: How to test URI query string length?

Now you put it that way it does seem rather obvious, thank you.