Length limit for JSON parameters on GET request

My Android application makes two GET calls for my server API. In the first case, this is where the code parameter is a string of 256 char.

 $.getJSON( myServerEndpoint, { action: "doStuff1", username: $("#username").val(), code: my256charString, format: "json" }) .done(function( data ) { doStuff2Response(data); }); 

The second is the one where the code parameter is a 5120 char string. Both users reach the same server endpoint.

 $.getJSON( myServerEndpoint, { action: "doStuff2", username: $("#username").val(), code: my5120CharString, format: "json" }) .done(function( data ) { doStuff2Response(data); }); 

When I call them both from the same device and the same user connected to Wi-Fi or most mobile data providers, it works fine.

However, when I connect from the Vodafone data connection, the second request never reaches the server. I can not find another explanation, except that there is a limit on the length of the parameters using Vodafone.

Any ideas or solutions?

+5
source share
2 answers

OK, so here it is. Read the following first: What is the maximum length of a URL in different browsers?

Yes, there is a β€œURL” length limit, but somehow I don’t know how to explain why this only happens for vodafone. Also, I don’t even know how the request goes through their servers anyway.

As for the solution, you should consider switching from a GET request to a POST request when the payload is too large.

+7
source

Quick fix: Base64 encodes part of the code message. Disadvantage: you have to decode on the server. This is a standard feature in most languages.

If you are already using Base64 or somesuch cypher, what about Blobs? https://developer.mozilla.org/en-US/docs/Web/API/Blob

The chromano offer is also available, just switch to POST and you will definitely receive an unlimited mail body. Downside: Have JSON.stringify and JSON.parse for yourself, and if you want to expose this URL to the user (say, as a sharing link), he can no longer carry the same information (URL - GET requests) .

+1
source

All Articles