-
Notifications
You must be signed in to change notification settings - Fork 113
Open
Labels
Description
I've got a translate request with trace:
[Client Request] {
host = translation.googleapis.com:443
secure = True
method = POST
timeout = ResponseTimeoutMicro 70000000
redirects = 10
path = /language/translate/v2
query = ?pp=true&alt=json
headers = authorization: Bearer BLAH BLAH BLAH; accept: application/json;charset=utf-8; content-type: application/json;charset=utf-8
body = {"format":"text","q":["hallo"],"model":"nmt","source":"de","target":"en"}
}
[Client Response] {
status = 200 OK
headers = content-type: application/json; charset=UTF-8; vary: Origin; vary: X-Origin; vary: Referer; content-encoding: gzip; date: Sun, 28 Jul 2019 11:37:19 GMT; server: ESF; cache-control: private; x-xss-protection: 0; x-frame-options: SAMEORIGIN; x-content-type-options: nosniff; alt-svc: quic=":443"; ma=2592000; v="46,43,39"; transfer-encoding: chunked
}
however it doesn't actually save anything into the variable:
TranslationsListResponse' {_tlrTranslations = Nothing}
Credentials are all good, I tried in wget and browser console and it was fine and returned proper response, but using this is just a response of Nothing...
Code:
{-# LANGUAGE OverloadedStrings, TemplateHaskell #-}
import Control.Monad
import Control.Lens
import Data.Function
import Data.Text
import Network.Google
import Network.Google.Translate
import System.Environment
import System.IO
main :: IO ()
main = do
lgr <- newLogger Trace stdout
setEnv "GOOGLE_APPLICATION_CREDENTIALS" "./google.json"
env <- newEnv <&> (envLogger .~ lgr) . (envScopes .~ cloudTranslationScope)
a <- runResourceT . runGoogle env $ send myR
print $ a^.tlrTranslations
myT :: TranslateTextRequest
myT = translateTextRequest & ttrFormat .~ Just "text" & ttrQ .~ ["hallo"] & ttrSource .~ (Just "de") & ttrTarget .~ (Just "en") & ttrModel .~ (Just "nmt")
myR :: TranslationsTranslate
myR = myT & translationsTranslate & ttPp .~ TrueThanks