-
-
Save ruzz311/5306139 to your computer and use it in GitHub Desktop.
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
// install the 'request' package first with 'npm install request' | |
var request = require('request'); | |
// replace with your Keen IO project token | |
var projectToken = "501999234-FAKE-PROJECT-ID"; | |
// create a sample JSON event for an event collection | |
var eventCollection = "meals"; | |
var sampleEvent = { | |
username: "ralph", | |
food: "pizza" | |
}; | |
// calculate the API URL | |
var apiUrl = "https://api.keen.io/3.0/projects/" + projectToken + "/events/" + eventCollection; | |
// perform a POST to the API using the request package | |
request({ | |
uri: apiUrl, | |
method: "POST", | |
json: sampleEvent | |
}, function(error, response, body) { | |
// response will be { "created": true } if successful | |
// console.log(body); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment