Created
February 21, 2017 04:54
-
-
Save chrismitchell/1d8c50888a6bd1de8abf962ba5c2ec15 to your computer and use it in GitHub Desktop.
Project creation for Keen.IO
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ORG_ID != ORGANIZATION_KEY
Caught me the first time 😊