Error 414 Google
Contents |
von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen
von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more http://stackoverflow.com/questions/18404668/google-translate-api-error-414-request-uri-too-large-java about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Google Translate Api error 414 (Request-URI Too Large) java up vote 1 error 414 down vote favorite In official documentation of Google Translate Api for Java it says that we can use post-method to send more than 2K characters. https://developers.google.com/translate/v2/using_rest However when I try to translate text more than 2k length I get error 414 (Request-URI Too Large). StringBuilder sb = new StringBuilder(); HttpURLConnection connection = null; try { URL url = new URL("https://www.googleapis.com/language/translate/v2"); String urlParameters = "key=" + apiKey + "&source=" + shortLang1 vpn error 414 + "&target=" + shortLang2 + "&q=" + URLEncoder.encode(lyrics, "UTF-8"); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setDoInput(true); connection.setDoOutput(true); connection.setUseCaches (false); connection.addRequestProperty("X-HTTP-Method-Override", "GET"); DataOutputStream wr = new DataOutputStream (connection.getOutputStream ()); wr.writeBytes (urlParameters); wr.flush (); wr.close (); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); if (connection.getResponseCode() != 200) { return null; } String line; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); } catch (Exception e) { e.printStackTrace(); } finally { if (connection != null) { connection.disconnect(); } } UPDATE: I got it, the code above is right. Finally I realize that I got this error not from Google Translate service but from my proxy on Google App Engine. java post google-translate share|improve this question edited Aug 26 '13 at 9:03 asked Aug 23 '13 at 13:56 user1049280 1,55072444 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote What the document you linked to is saying is that you use the POST method and you put the parameters into the request body ... not the request URL. Reference: How are parameters sent in an HTTP POST request? share|improve this answer answered Aug 23 '13 at 14:18 Stephen C 387k45411738 Thank you for reply, but I'm afraid I don't understand