nidhipanchal2207 / google-api-translate-java

Automatically exported from code.google.com/p/google-api-translate-java
0 stars 0 forks source link

Error 400 #161

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
My Code is 

public String gtans()
    {

        String trans = null;
            try {
                GoogleAPI.setHttpReferrer("https://localhost/oauth2callback");
                //GoogleAPI.setHttpReferrer("https://www.googleapis.com/language/translate/v2");
                GoogleAPI.validateReferrer();
            } catch (Exception ex) {
                Logger.getLogger(GoogleTransalte.class.getName()).log(Level.SEVERE, null, ex);
            }
        try {
        GoogleAPI.setKey("ugCHXLVC8UEDojKqSU3gzCOZ");
            trans = Translate.DEFAULT.execute("Hello", Language.ENGLISH, Language.HINDI);
            } catch (GoogleAPIException ex) {
            Logger.getLogger(TranslateView.class.getName()).log(Level.SEVERE, null, ex);
        }
        return trans;
    } 

I should get the translation of hello, I am geting the error

Error: [google-api-translate-java] Error retrieving translation.
11 Feb, 2012 11:56:11 PM translate.GoogleTransalte gtans
SEVERE: null
com.google.api.GoogleAPIException: java.lang.Exception: 
[google-api-translate-java] Error retrieving translation.
        at com.google.api.translate.TranslateV2.execute(TranslateV2.java:68)
        at translate.GoogleTransalte.gtans(GoogleTransalte.java:33)
        at translate.TranslateView.jButton1ActionPerformed(TranslateView.java:240)
        at translate.TranslateView.access$800(TranslateView.java:22)
        at translate.TranslateView$4.actionPerformed(TranslateView.java:134)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6038)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
        at java.awt.Component.processEvent(Component.java:5803)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4410)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2429)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.lang.Exception: [google-api-translate-java] Error retrieving 
translation.
        at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:99)
        at com.google.api.translate.TranslateV2.execute(TranslateV2.java:62)
        ... 29 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for 
URL: 
https://www.googleapis.com/language/translate/v2?key=ugCHXLVC8UEDojKqSU3gzCOZ&q=
Please+Help+Me.&target=hi&source=en
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1298)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1292)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:948)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
        at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:93)
        ... 30 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for 
URL: 
https://www.googleapis.com/language/translate/v2?key=ugCHXLVC8UEDojKqSU3gzCOZ&q=
Please+Help+Me.&target=hi&source=en
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
        at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:89)
        ... 30 more

What version of the product are you using? On what operating system?
I am using Netbeans 6.5, google api 0.97.

Please provide any additional information below.

Original issue reported on code.google.com by njoshi...@gmail.com on 11 Feb 2012 at 6:32