4
votes

I would like to use the http-enumerator package to perform not only GET/POST but also PUT.

http-enumerator:
http://hackage.haskell.org/package/http-enumerator
http://hackage.haskell.org/packages/archive/http-enumerator/0.6.5/doc/html/Network-HTTP-Enumerator.html

*) my first step was to construct a Request and print it.
However I failed to write a proper Show function (error "No instance for Show .. arising from a use of print").

*) next I think I have to use the function "httpLbs :: MonadIO m => Request m -> Manager -> m Response" to get the Response.

for people who search and need that info too: haskell, REST or restful request, http, rest api access

1

1 Answers

5
votes

http-enumerator/http-conduit doesn't really care if you're using POST, PUT, DELETE, etc. You just need to change the method record of the Request datatype. Your best bet is to rely on OverloadedStrings for this, something like:

{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Enumerator

main = do
    req <- parseUrl "http://www.example.com/put-url"
    withManager $ httpLbs req { method = "PUT" }

HTH