cyril
cyril

Reputation: 3006

Google Translate API - Error code 500 Backend Error

I'm submitting various queries to Google Translate API via Google API's Python module. Occasionally I receive the error message below:

from googleapiclient.discovery import build

service = build('translate', 'v2', developerKey='my_key')
translation = service.translations().list(
                    source='zh',
                    target='en',
                    q=text_for_translation).execute()

HttpError: HttpError 500 when requesting https://www.googleapis.com/language/translate/v2?q=%E7%B7%9A&source=zh&alt=json&target=en&key=my_key returned "Backend Error">

Any ideas why this is happening and how to avoid it? I can't find any info on this particular problem.

I seem to get the error randomly, as nearly all of the queries I submit for translation return without any problems. Also, if I re-submit the exact same query it will return successfully.

Upvotes: 2

Views: 1446

Answers (1)

David Barda
David Barda

Reputation: 1010

From google API FAQ page:

This could happen if you submit text without the source language specified. If Google cannot determine the source language given the text (usually because the text is too short), we will return a 500. This situation can be fixed by specifying the source language explicitly.

For more and other information Google translate API

Upvotes: 2

Related Questions