Hi @Stephane_Caron,
The reason why you are not able to call
client.statusupdates.getStatus(statusGid, {param: "value", param: "value", opt_pretty: true})
Is because the asana node client doesn’t know about this getStatus
method or the statusupdates
class even though the getStatus
method exists in the v1.0.2 library.
This probably happened because our v1 library relies on a mix of auto generation + manual editing to get new resource endpoints working. We’re working on a v2 of our node-asana client library which should help us with keeping our client library up-to-date with our API. (v2 is in Beta right now at v2.X.X)
Here’s a quick explanation and example of why one method works vs why this one doesn’t.
WORKING (EX: tasks.getTask):
- The
getTask
method is defined in /gen/tasks.js (this file was auto generated by our code generator)
- In the /resources folder, there is a file for tasks.js which imports the generated method definitions from
/gen/tasks.js
- The client.js knows about tasks because
this.tasks = new resources.Tasks(this.dispatcher);
is defined → this is why you can call client.tasks
NOT WORKING (EX: statusupdates.getStatus
):
- The
getStatus
method is defined in /gen/status_updates.js (this file was auto generated by our code generator)
- In the /resources folder, it is missing a file for
status_updates.js
which should import the auto generated methods defined in the /gen/status_updates.js
file
- The client.js is missing a a definition for
this.statusupdates = new resources.StatusUpdates(this.dispatcher);
→ this is what I meant by the client not knowing about statusupdates
TLDR; this is a bug with the v1 node library.
The workaround is to use our dispatcher method that is in our v1.0.2 node-asana library. You can use this to call any API endpoints that the v1.0.2 library does not have define. Here’s an example of how you would make a request to getStatus
:
const asana = require('asana');
const client = asana.Client.create().useAccessToken("<YOUR_ASANA_PERSONAL_ACCESS_TOKEN>");
statusGid = "<YOUR_STATUS_GID>"
path = `/status_updates/${statusGid}`
client.dispatcher.get(path, {}, {}).then((data) => {
console.log(JSON.stringify(data, null, 2));
})
Here’s the definition for that dispatcher.get
method:
/**
* Dispatches a GET request to the Asana API.
* @param {String} path The path of the API
* @param {Object} [query] The query params
* @param {Object} [dispatchOptions] Options for handling the request and
* response. See `dispatch`.
* @return {Promise} The response for the request
* @param path
* @param query?
* @param dispatchOptions?
* @return
*/
get(path: string, query?: any, dispatchOptions?: any): Promise<any>;