How to test URI query string length? | Community
Skip to main content
Mike_Dinnis
Level 2
Jul 31, 2019 7:31 AM UTC
Solved

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Jul 31, 2019 8:02 AM UTC

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.

4 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Jul 31, 2019 8:02 AM UTC

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.

Translate
Mike_Dinnis
Level 2
Jul 31, 2019 8:07 AM UTC

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.

Translate
SanfordWhiteman
Level 10
Jul 31, 2019 8:19 AM UTC

 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. 

Translate