Skip to content

Instantly share code, notes, and snippets.

@chrismitchell
Created February 21, 2017 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismitchell/1d8c50888a6bd1de8abf962ba5c2ec15 to your computer and use it in GitHub Desktop.
Save chrismitchell/1d8c50888a6bd1de8abf962ba5c2ec15 to your computer and use it in GitHub Desktop.
Project creation for Keen.IO
require 'net/http'
require 'uri'
uri = URI.parse("https://api.keen.io/3.0/organizations/ORG_ID/projects")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request["Authorization"] = "ORGANIZATION_KEY"
request.body = "{
\"name\": \"My First Project\",
\"users\": [
{
\"email\": \"<USER_EMAIL>\"
},
{
...
},
...
],
\"preferences\": {
\"s3_bucket_name\": \"<S3_BUCKET_NAME>\"
}
}"
req_options = {
use_ssl: uri.scheme == "https",
}
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
# response.code
# response.body
@chrismitchell
Copy link
Author

ORG_ID != ORGANIZATION_KEY

Caught me the first time 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment