Google-cloud-php: Translate EAP Premium - BadRequestException with large text

Created on 23 Nov 2016  路  5Comments  路  Source: googleapis/google-cloud-php

Hello !

We are in the Early Access Program for Google Translate Premium Beta, and with the last 芦 master 禄 branch of your PHP API, this works perfectly with short sentences ( we receive in return the 芦 nmt 禄 field confirmation ).

But for long text ( tested with a text of about 2500 characters ), we have an error:

[error] 1165#0: *198 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Google\Cloud\Exception\ServiceException: Client error: `GET https://translation.googleapis.com/language/translate/v2?model=nmt&format=text&q=Le%20progiciel%20de%20gestio (...)

May be it's because the text is too long for an URL request through GET method.
So I tried to change the HTTP method from GET to POST in the 芦 translate-v2.json 禄 definition (line 215). This still works for short sentence but not for long sentence.

Thanks in advance for your time and your help :)

translation triage me

All 5 comments

Thanks for the report @lakano, taking a look now.

You were spot on with the text being too long for the content to be in the URL.

The q parameter which contains the text to be translated is still assigned as a query param - we will need to get the definition updated with the latest rules in order to send the text as part of the body. After checking the discovery API it looks like the latest definition which should handle that has not been released yet. Will check in and see when we can expect those changes, worst case scenario we can update the definition manually until we get the official update.

Thanks for the quick feedback 馃憤
So, there is no manual quick workaround I can do now to bypass the problem?
If you known which file in the google-cloud-php package send the POST request, I could surely remove manually any GET parameters (we only use the google-cloud-php package for Translate NMT).
Thanks :)

It looks like there are still a few outstanding issues before the discovery doc will be updated officially. In the meantime, since you are in the EAP program let me know if using this service definition does the trick for you. :)

https://gist.github.com/dwsupplee/eb75e35ae96dd829387ab27e64e9aa47

Yes ! Thanks for the quick fix :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tmatsuo picture tmatsuo  路  4Comments

matthewgoslett picture matthewgoslett  路  4Comments

castaneai picture castaneai  路  7Comments

LoekvanKooten picture LoekvanKooten  路  6Comments

smalot picture smalot  路  6Comments