First of all, I have never used an API before, and I have never used an HTTP library in Haskell. I'm not sure what I'm doing wrong here, so maybe someone who knows can help.
I am using what I can read: http://github.com/defunkt/gist/blob/master/gist.rb , namely the write method, to write this:
req = postRequest "http://gist.github.com/gists/new" testPost = simpleHTTP $ req {rqBody = urlEncodeVars [("login", "Raynes"), ("token","<removed>"), ("file_ext[gistfile1]",".hs"), ("file_name[gistfile1]","testfile"), ("file_contents[gistfile1]","main = putStrLn \"Hello, world!\"")]}
When run, testPost gives this result:
Right HTTP/1.1 302 Found Server: nginx/0.7.61 Date: Sun, 29 Nov 2009 17:13:51 GMT Content-Type: text/html; charset=utf-8 Connection: close Status: 302 Found Location: http://gist.github.com/gists/new X-Runtime: 1ms Content-Length: 98 Set-Cookie: _github_ses=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA%3D%3D--884981fc5aa85daf318eeff084d98e2cff92578f; path=/; expires=Wed, 01 Jan 2020 08:00:00 GMT; HttpOnly Cache-Control: no-cache
As far as I know, the location should be a link to the new Gist. However, a new Gist is not created. I'm not sure what I'm doing wrong. There is basically no documentation for the Gist API, and I can only assume that I'm not translating Ruby correctly. As I said, I have never used the HTTP library before.
Any help is appreciated.
Rayne source share