Byron/google-apis-rs

Google Translate v2 API returns an empty response for a simple query

festeh opened this issue · 2 comments

festeh commented

Hi!

I wanted to run a simple query like

 hub
    .translations()
    .list(
        &vec![
            "Was wollen Sie sagen?".to_string(),
        ],
        "en",
    )
    .doit()
    .await;

but I got an empty TranslationsListResponse.

I dig into sources and found out that actual json body of http response is fine

res_body_string = : {
  "data": {
    "translations": [
      {
        "translatedText": "What do you want to say?",
        "detectedSourceLanguage": "de"
      }
    ]
  }
}

but when it converted into TranslationsListResponse, the translations field is none. I think it's due to a "data" key in response. WDYT?

Byron commented

It could be that the API description has changed, so the datatypes and what the API actually responds with is now different. As immediate fix, you could vendor the sources and patch it. Otherwise, I recommend checking in the README how to update the API descriptions to regenerate the API. Maybe the latest version has updated data-structures.

festeh commented

Thanks for the response!