Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `{"errors":[{
- "message":"Could not parse request data,invalid JSON",
- "help":"For more information on API status codes and how to handle them,
- read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}
- ]}`
- testTask(){
- var taskName = "Test Name for a Test Task"
- var workspaceID = "123456789"
- var projectID = "123456789"
- var assigneeID = "123456789"
- var parentID = null
- this.createTask(taskName, workspaceID, projectID, assigneeID, parentID)
- }
- createTask(taskName, workspaceID, projectID, assigneeID, parentID){
- var token = "0/784e23edf34ef5642dXGT0432"
- var bearerToken = "Bearer " + token
- var task = {
- data: {
- assignee: "me",
- notes: "test test test test",
- workspace: workspaceID,
- name: taskName,
- projects: [projectID],
- parent: parentID
- }
- }
- var options = {
- "method" : "POST",
- "headers" : {"Authorization": bearerToken},
- "contentType": "application/json",
- "payload" : JSON.stringify(task)
- }
- try {
- var url = "https://app.asana.com/api/1.0/tasks";
- request.post(url, options, function optionalCallback(err, httpResponse, body) {
- if (err) {
- return console.error('upload failed:', err);
- }
- console.log('Upload successful! Server responded with:', body);
- });
- }
- catch (e) {
- console.log(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement