5 years, 9 months ago.

Square brackets not allowed in GET request?

Hi,

HTTPClient is giving me an "Error - ret = -9 - HTTP return code = 0" when using square brackets [] in a GET request:

ret = http.get("http://dummy.server.org/test?id=55&fields[]=name", str, sizeof(str));

A request without square brackets returns fine. Am I missing something or is this really a limitation of HTTPClient library?

Question relating to:

Fixed HTTP header key and value length.

1 Answer

5 years, 9 months ago.

It's not a limitation of the library, it's a limitation of the URL specification, [ and ] are invalid characters. Replace them with %5B and %5D and it should work.

Thanks Andy, I did try percent-encoded, but I still get the same error... (There seem to be quite a few issues with square brackets as they are valid in RFC3986?)

posted by Oliver Walkhoff 18 May 2015