Skip to content

Instantly share code, notes, and snippets.

@azat-co
Created November 18, 2014 02:07
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 azat-co/85f45f4ac8bb85058a42 to your computer and use it in GitHub Desktop.
Save azat-co/85f45f4ac8bb85058a42 to your computer and use it in GitHub Desktop.
Asana Hello World Node API Example
var request = require('request')
var apiKey = process.env.API_KEY
var workspaceId = process.env.WORKSPACE
var assigneeEmail = process.env.ASSIGNEE
var url ='https://app.asana.com/api/1.0/tasks'
// set up the request
var headers = {
'Authorization': 'Basic '+ new Buffer(apiKey).toString('base64')
}
var body = {
data: {
'workspace': workspaceId,
'name': 'Hello World!!!',
'assignee': assigneeEmail
}
}
// set up HTTPS connection
// json option will auto-add the application/json header
request.post({url:url, headers: headers, json: body}, function (e, r, body) {
// output
if (e || body['errors'])
console.log('Server returned an error: '+ body['errors'][0]['message'])
else {
console.log('Created task with id: ' + body['data']['id'])
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment