client.statusupdates.getStatus not working

Hi,

I am trying to get the status of a project. Being more specific this value:

"status_type": "on_hold"

If I execute

/status_updates/{status_guid}

I get this value, good so far.

"data": {
         "gid": "1202108306050098",
         "created_at": "2022-04-11T14:59:03.974Z",
         .
         .
         .
         "resource_type": "status_update",
         "resource_subtype": "project_status_update",
         "status_type": "on_hold",

However, in the documentation (https://developers.asana.com/docs/status-updates), it states that endpoint is called with

client.statusupdates.getStatus(statusGid)

but when I execute it in nodejs it reports

TypeError: Cannot read property 'getStatus' of undefined

because there is no object called “statusupdates” in client (I checked browsing the object in VS).

So I have 3 questions, any support here will be appreciated

1)What is the method to call /status_updates/{status_guid} ?
2)Seems the documentation is not aligned with the node-asana. I am using version 0.18.6. Am I doing something wrong?
3)To get the status_type I am first getting the project detail with

client.projects.getProject(gid);

which calls

/projects/{gid}

and returns

"data": {
        "gid": "1202018361552925",
        "archived": false,
        .
        .
        .
        "current_status": {
            "gid": "1202108306050098",

and in project detail I get the status gid and then call the /status_updates, so these are 2 calls. Is there any way to get the project detail along with the status_type is one single call?

Thank you.

Nowhere in the documentation it says so and your link does not lead to the right section of the doc I believe.

What you did not realise is that you can use getProject and use opt_fields to request details for the status. So in a single call you can have it all. For example opt_fields could be gid,name,current_status.color, current_status.title, current_status.text…

Does this help?

Hi Bastien, thank you for your reply.

In the link I posted (https://developers.asana.com/docs/status-updates), if you select “node” in the code samples, it’s shown
image

If I use opt_fields, if I am not wrong, I can only “filter” the fields returned but cannot ask for more.

I mean, from getProject, the current_status object contain

current_status": {
            "gid": "1202108306050098",
            "author": {
                "gid": "1202018329436005",
                "resource_type": "user"
            },
            "color": "blue",
            "created_at": "2022-04-11T14:59:03.974Z",
            "created_by": {
                "gid": "1202018329436005",
                "resource_type": "user"
            },
            "modified_at": "2022-04-11T14:59:03.974Z",
            "resource_type": "project_status",
            "text": "Tasks status\nCompleted tasks as of Apr 11, 2022\n",
            "title": "Pending vendor"
        }

I am looking for the “status_type” which unfortunately is not returned in the getProject.

I need to call the

/status_updates/{status_guid}

passing the gid obtained before, in this case 1202108306050098

and then I get

"data": {
         "gid": "1202108306050098",
         .
         .
         .
         "resource_type": "status_update",
         "resource_subtype": "project_status_update",
         "status_type": "on_hold",

Thank you

I believe that is not always the case and you can ask for things normally not returned to you. You should try!

There are two entities of interest in your case, current_status and current_status_update. The status_type equivalent I believe is the color in the current_status. That’s what I am using for my tools, and blue is the on hold.

The truth is in the code, so you can open up the source of the nodeJS asana lib in node_modules and see for yourself. I did not find it in mine, but I might not be running the latest asana lib, maybe you need to update as well.

Hi Bastien, I tried some of your recommendations.

You’re right. If I

/projects/1202018361552925

equivalent to

client.projects.getProject("1202018361552925")

returns no “status_type”, but if I include it with opt_fields it suddenly appears

So I do

/projects/1202018361552925?opt_fields=gid, current_status_update.status_type

and i get

{
    "data": {
        "gid": "1202018361552925",
        "current_status_update": {
            "gid": "1202108306050098",
            "status_type": "on_hold"
        }
    }
}

So definitely I don’t need to make a call to status_updates, thanks for this. :slightly_smiling_face:

On the other hand related to the status_updates

/status_updates/1202108306050098

is supossed to be equivalent to

client.statusupdates.getStatus("1202108306050098")

but does not exist in version 0.18.4

I have seen that in client.js is not included (https://github.com/Asana/node-asana/blob/master/lib/client.js)

but in the library it exists https://github.com/Asana/node-asana/blob/master/lib/resources/gen/status_updates.js

so probably is some kind of bug.

So as a summary of all this dicussion:

  • The node-asana 0.18.4 is missing the status_updates.js in the client (if I am not wrong)
  • Your suggestions about “I believe that is not always the case and you can ask for things normally not returned to you. You should try!” is totally true.

Thanks a lot.
Marcos.

1 Like