Skip to content

Instantly share code, notes, and snippets.

@refiito
Forked from bgwaltney/ExampleRequest.js
Last active January 13, 2017 10:37
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 refiito/d275eb14028cef6b2bc969e63d8faff9 to your computer and use it in GitHub Desktop.
Save refiito/d275eb14028cef6b2bc969e63d8faff9 to your computer and use it in GitHub Desktop.
function createProjectSpecialists(project_name){
var templateID = xxxx;
request({'url': 'https://www.toggl.com/api/v9/workspaces/xxx/projects', //URL to hit
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
'auth': {
'user': settings.passwords.toggl_key,
'pass': 'api_token'
},
'json': {
"project":{
"name": project_name,
//"wid":xxx, <-- not needed here, move to the part of the URL
"template_id": templateID,
"is_private":false
}}
}, function(error, response, body){
if(error) {
console.log(error);
context.done(null, error);
} else {
if(response.statusCode == 200){
console.log(response.statusCode, "toggl specialist project was created");
}
else{
console.log(response.statusCode, "toggl specialist project was NOT created");
console.log(body)
}
}
});
} // end of create project function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment