1

I'm making a GET request using the PARSE API. I'm getting a "414 Request-URI Too Large" error, but I don't understand why. Here is the code for my request:

 $.ajax({ 
      url : 'https://api.parse.com/1/classes/chats',
      type : 'GET',
      dataType: 'json',
      data : JSON.stringify({   
        order: '-createdAt',    
      }),
      success : function(data) {
        handleData(data)
      },
      error : function(data) {
        console.log('error: ' + data);
      }
    });
user27828
  • 13
  • 1
  • 3
  • That error is coming from the backend; your example creates the url `https://api.parse.com/1/classes/chats?{%22order%22:%22-createdAt%22}`. – Elliott Frisch Nov 23 '13 at 02:33
  • @ElliottFrisch I'm not following. What do you mean by the error is coming from the backend? – user27828 Nov 23 '13 at 02:38
  • 1
    `414 Request-URI Too Large` is the [response code](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error) from the server. Specifically, you're sending too much data in request; and the server is telling you to use a `POST` and will not allow you to use `GET`. – Elliott Frisch Nov 23 '13 at 02:50
  • @ElliottFrisch That's what I don't understand, how I could be sending too much data in the request. Also, despite the error, the function containing the GET request seems to be working fine. – user27828 Nov 23 '13 at 02:56
  • What do you see on the console? Specifically, a line starting 'error:'. – Elliott Frisch Nov 23 '13 at 02:57
  • @ElliottFrisch The console displays "Uncaught SyntaxError: Unexpected token < " and provides the 'too long' URL. When you follow the URL, you come to the 414 Error. – user27828 Nov 23 '13 at 03:05
  • Add a [try catch](http://www.javascriptkit.com/javatutors/trycatch.shtml). Your actual problem isn't visible here. – Elliott Frisch Nov 23 '13 at 03:12
  • Added a try/catch, but the catch isn't throwing an error. – user27828 Nov 23 '13 at 03:21

1 Answers1

5

Because the server says so, e.g. the service you're querying against is so configured. From Wikipedia

414 Request-URI Too Long The URI provided was too long for the server to process - The HTTP/1.1 Specification. Often the result of too much data being encoded as a query-string of a GET request, in which case it should be converted to a POST request.

Community
  • 1
  • 1
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249