TFPHTTPClient get ERROR 414 Request-URI Too Large from server lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- DidaJI · 2020-01-14 06:00 Hi, I have a problem with communication with the server via the TFHTTPClient component. PHP scripts are running on the server side. I use the POST method and as long as the request size is less than 8192 bytes, everything is OK. However, if the request grows to a size above 8192 bytes (sending photos in BASE64 format), the server returns an error: 414 Request-URI Too Large. On the server (Apache) I have set the POST query size to 32MB. Anyone know how to solve it? I need to send a request of about 50KB. Thank's: Zdenek. ---------------------------------------------------------------------- trev · 2020-01-14 06:17 Perhaps the web browser you're using has a size limit? ---------------------------------------------------------------------- DidaJI · 2020-01-14 06:47 If I try to call php script on server from a browser and send it a 50KB request, it normally works. It's not just from the program. ---------------------------------------------------------------------- trev · 2020-01-14 07:06 What does the web server log show? ---------------------------------------------------------------------- DidaJI · 2020-01-14 07:47 I use Synology NAS as a server. There is nothing about this query in the Apache error log, and the Acces log does not know where to find the Synology. I would have to install Apache on another PC and try it out there. Then I get to all the logs. ---------------------------------------------------------------------- DidaJI · 2020-01-14 09:26 The problem seems to be that I am entering data directly into the url and it can only be 8192 characters long. Simplified: url := 'http://192.168.64.2/test/' + 'action.php?ID=1' + '&data=' + Base64Str; HTTPClient := TFPHTTPClient.Create(nil); html := HTTPClient.Post(url);    This works if Base64Str is less than 8192 bytes. In the case of longer data, this will probably have to be entered somehow other than directly into the url. Would anyone know how? ---------------------------------------------------------------------- trev · 2020-01-14 11:49 See the Wiki post example: https://wiki.lazarus.freepascal.org/fphttpclient ---------------------------------------------------------------------- DidaJI · 2020-01-14 13:29 So it works, it was necessary to use FormPost and pass the data as a parameter and not in the URL. ---------------------------------------------------------------------- hedmondjohn · 2022-12-28 07:59 This rare condition is only likely to occur when a client has improperly converted a POST request to a GET request with long query information. The HTTP 414 URI Too Long response status code indicates that the URI(Uniform Resource Identifier) requested by the client is longer than the server is willing to interpret. To resolve this problem : By POST request: Convert query string to json object and sent to API request with POST. By GET request: Max length of request is depend on sever side as well as client side. Most webserver have limit 8k which is configurable. On the client side the different browser has different limit. The browser IE and Safari limit to 2k, Opera 4k and Firefox 8k. This means that the max length for the GET request is 8k and min request length is 2k. If exceed the request max length then the request truncated outside the limit by web server or browser without any warning. Some server truncated request data but the some server reject it because of data lose and they will return with response code 414 Under Apache, the limit is a configurable value, LimitRequestLine. If you want to increase URL limit to 5000 characters (bytes), add the following lines to your server configuration or virtual host file. LimitRequestLine 5000 If you want to increase maximum header length supported by Apache to 3000 characters, then add the following line. LimitRequestFieldSize 3000 ---------------------------------------------------------------------- Thaddy · 2022-12-28 08:12 The payload should be in TfpHttpClient.RequestBody before you post. Indeed NOT in the URL. There are no limitations other than the protocol may describe. Within that constraint the requestBody takes a TStream of any size. Also, the requestHeader should contain the content type. e.g. application/json etc, otherwise the protocol can not handle the body correctly.