[Haskell-beginners] Network.HTTP.Conduit - body in REST/POST request
Miro Karpis
miroslav.karpis at gmail.com
Wed May 28 12:48:19 UTC 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140528/e9bd2f63/attachment.html>
More information about the Beginners
mailing list