Asana / node-asana

Official node.js and browser JS client for the Asana API v1
MIT License
264 stars 74 forks source link

'created_by' property is missing from returned data #285

Closed mhmostafa88 closed 1 year ago

mhmostafa88 commented 1 year ago

Before the recent update, the 'created_by' property used to exist, but now it's missing from the returned task object. It's true that this property doesn't exist in the asana api documentation, but it does exist, it's an undocumented property (see this thread in the asana forum )

jv-asana commented 1 year ago

Hi @mhmostafa88, thanks for reporting this. Let me check in with the team on why we don't document this. After confirmation, I can send a fix for this issue for the TaskApi.

In the mean time, the workaround would be to call:

const Asana = require('asana');
const defaultClient = Asana.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
const oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = "<YOUR_PERSONAL_ACCESS_TOKEN>";

// GET - get a task
defaultClient.callApi(
  "/tasks/{task_gid}",
  "GET",
  (pathParams = { task_gid: "<YOUR_TASK_GID>" }),
  (queryParams = {opt_fields: ["created_by"]}),
  (headerParams = {}),
  (formParams = {}),
  (bodyParam = null),
  (authNames = ["oauth2"]),
  (contentTypes = []),
  (accepts = ["application/json; charset=UTF-8"]),
  (returnType = "Blob"), // Can be one of: "Blob", "String"
  (callback = (error, data, response) => {
    if (error) {
      console.error(error);
      throw new Error(error);
    } else {
      console.log("API called successfully. Returned data: " + JSON.stringify(JSON.parse(data), null, 2));
    }
  })
);

Example output:

API called successfully. Returned data: {
  "data": {
    "gid": "<YOUR_TASK_GID>",
    "created_by": {
      "gid": "<USER_GID>",
      "resource_type": "user"
    }
  }
}
mhmostafa88 commented 1 year ago

I am so sorry I just realized that i meant to post this on python-asana sdk library not node-asana.