First of all, I've never really used APIs before, and I've never used the HTTP library in Haskell. I'm not sure what I'm doing wrong here, so maybe somebody who knows can help.
I'm using what I can read of this: 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 ran, testPost gives this output:
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, no new Gist is made. I'm not sure what I'm doing wrong. There is basically no documentation for the Gist API, and the only thing I can assume is that I'm not translating the Ruby correctly. Like I said, I've never really used the HTTP library before.
Any help is appreciated.