Fix HttpError 400 "Too many text segments"

1,116 views
Skip to first unread message

stephenh...@u.northwestern.edu

unread,
Jun 17, 2016, 3:33:35 PM6/17/16
to Google Translate API Developer Forum
I am trying to translate a list of Chinese names to English but when I use q=[] I receive
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/language/translate/v2 returned "Too many text segments">


I am translating 200 for now but I need to translate about 1000 Chinese names into English.  How does one do this?  Can it be done by reading a .txt file instead of using q=[]?  Many thanks.  Steve

Nick

unread,
Jun 20, 2016, 3:18:31 PM6/20/16
to Google Translate API Developer Forum
By "using q=[]", do you mean that you supply multiple values for q in the query, like this: q=asdfg&q=hjkl&q=qwerty&q=uiop ?

You could attempt to make multiple requests with fewer names in each request. Let me know how that goes.

Cheers,

Nick
Cloud Platform Community Support

Nick

unread,
Jun 23, 2016, 4:30:53 PM6/23/16
to Google Translate API Developer Forum
Any updates on my last question? It's not clear exactly what's causing the issue here. Maybe you could supply some example requests and responses?

thomas...@lionbridge.com

unread,
Jan 9, 2017, 2:23:37 PM1/9/17
to Google Cloud Translation API
Hi Nick,

I am getting the same error message "Too many text segments, Domain: global, Reason: invalid" is there a limit as to how many 'q' segments you can send in one request ?

Thanks

Nick

unread,
Jan 10, 2017, 10:29:22 AM1/10/17
to Google Cloud Translation API
I'm not aware of any such limitation, although it could be possible. How many segments are you sending? There's a thread which is several years old now showing some users had noted a limit at 128. You could attempt to break up the requests into smaller sizes and batch them. Let me know how that goes.

lixiang yin

unread,
Apr 2, 2018, 9:50:22 AM4/2/18
to Google Cloud Translation API
Hi Nick,

I am using python api of google translator as below:
from google.cloud.translate_v2.client import Client
client = Client.from_service_account_json(auth_json)
paragraphs = ['p1', 'p2', 'p3'...]
res = client.translate(paragraphs, target_language='zh-CN')
and get a similar error message:

error : 400 POST https://translation.googleapis.com/language/translate/v2: Too many text segments


with the length of input paragraphs list is 240 and I figure out that two other successful paragraphs's length are 89 and 33.

So it seems the magic number 128 is the limit as posted above.

However, as a commercial service, is there any document specifying this critical limit?

Thanks
Reply all
Reply to author
Forward
0 new messages