
so this did the trick:
test :: IO ()
test = do
r <- parseUrl $ "http://localhost:3000/readbody"
let r_ = urlEncodedBody [("?nonce:", "2"), ("&method", "getInfo")] r
let request = r_
{ requestBody = (RequestBodyBS s)}
response <- withManager $ httpLbs request
putStrLn $ show request
print $ responseBody response
On Wed, May 28, 2014 at 2:48 PM, Miro Karpis
Hi, I'm having difficulties with sending body parameters/values in a POST request. It seems that the server does not receive in body.
ideas/comments very welcome ;-)
cheers, m.
{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Conduit import Data.Word(Word8) import Data.ByteString.Lazy(pack) import qualified Data.ByteString.Char8 as B
x :: B.ByteString x = "?value=10"
post = do r <- parseUrl "http://postcatcher.in/catchers/5385d4e0b6887c0200000071" putStrLn $show r let request = r { secure = True , method = "POST" , requestBody = RequestBodyBS s , requestHeaders = (requestHeaders r) ++ [("Content-Type", "application/json")]} putStrLn $ show request response <- withManager $ httpLbs request print $ responseBody response