Skip to content

Instantly share code, notes, and snippets.

@meltingice
Created October 25, 2012 21:29
Show Gist options
  • Save meltingice/3955550 to your computer and use it in GitHub Desktop.
Save meltingice/3955550 to your computer and use it in GitHub Desktop.
RestClient + the 37Signals API
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