Created
October 25, 2012 21:29
-
-
Save meltingice/3955550 to your computer and use it in GitHub Desktop.
RestClient + the 37Signals API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_post(account_id, endpoint, params={}) | |
r = RestClient::Resource.new( | |
api_url(account_id) + endpoint + ".json", | |
:headers => headers | |
) | |
# RestClient doesn't convert the POST parameters to | |
# JSON, so we have to do it manually. This was the | |
# big gotcha, and why we were getting 415 Unsupported | |
# Media Type as the error response. | |
resp = r.post params.to_json | |
JSON.parse(resp) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment