Im trying to convert this curl request to HTTP-Conduit one:
curl -v https://api.sandbox.paypal.com/v1/identity/openidconnect/userinfo/?schema=openid -H "Content-Type:application/json" -H "Authorization:Bearer -AxLVv0fegyk-opT.2sG5JGQ3VNHUL08WpWkO3s7tVI"
My haskell code is :
{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Conduit
import Data.ByteString.Char8
import qualified Data.ByteString.Lazy as L
import Network.HTTP.Types.Header
import Network (withSocketsDo)
import Control.Failure
import Network.HTTP.Types
getReq :: Failure HttpException m => m Request
getReq = parseUrl "https://api.sandbox.paypal.com/v1/identity/openidconnect/userinfo/?schema=openid"
getRequestHeaders :: RequestHeaders
getRequestHeaders = [ ( "Content-Type" , "application/json")
, ( "Authorization" , "Bearer -AxLVv0fegyk-opT.2sG5JGQ3VNHUL08WpWkO3s7tVI")
]
main :: IO ()
main = do
req0 <- getReq
let req = req0 { method = methodPost
, requestHeaders = getRequestHeaders
}
res <- withManager $ httpLbs req
L.putStrLn $ responseBody res
When running main getting this error :
*** Exception: TlsException (HandshakeFailed (Error_Packet_unexpected "Alert [(AlertLevel_Fatal,DecryptError)]" " expected: change cipher"))
Any help?
UPDATE:
Running
cabal list --installed HTTP-Conduit
cabal list --installed tls
Got me this response
* http-conduit
Synopsis: HTTP client package with conduit interface and HTTPS support.
Default available version: 2.0.0.4
Installed versions: 1.9.4.5
Homepage: http://www.yesodweb.com/book/http-conduit
License: BSD3
* http-client-tls
Synopsis: http-client backend using the connection package and tls library
Default available version: 0.2.0.3
Installed versions: 0.2.0.3
Homepage: https://github.com/snoyberg/http-client
License: MIT
* tls
Synopsis: TLS/SSL protocol native implementation (Server and Client)
Default available version: 1.2.2
Installed versions: 1.1.5
Homepage: http://github.com/vincenthz/hs-tls
License: BSD3
* tls-extra
Synopsis: TLS extra default values and helpers
Default available version: 0.6.6
Installed versions: 0.6.5
Homepage: http://github.com/vincenthz/hs-tls
License: BSD3
I ran cabal install to update both tls , http-conduit and still got the same error.