0

I am looking to implement a solution where when I create a project in Asana it will create a room in Slack with all the same members.I was planning on writing a script to run every couple of minutes to look for either new projects or changes in membership of current projects and then call out to slack to make the changes. This, however, would be a lot of chatter so I was hoping someone might know of and be able to recommend another way that will make these changes on an as needed basis.

Sean C.
  • 23
  • 5

1 Answers1

0

It sounds like you have the best solution outlined for this use case.

In order to get a list of new projects in a workspaces you should query the projects endpoint and check for newly created projects based on the created_at field, using opt_fields field selector to have that returned in your query. I strongly suggest that you scope this query to a single workspace and use pagination.

GET 'https://api.asana.com/api/1.0/workspaces/5233820891524/projects?opt_fields=name,created_at&limit=2' | j
{
  "data": [
    {
      "id": 23154287843671,
      "created_at": "2014-12-31T18:35:49.695Z",
      "name": "Ninja Things"
    },
    {
      "id": 23154287843675,
      "created_at": "2014-12-31T18:35:59.174Z",
      "name": "Unicorns"
    }
  ],
  "next_page": {
    "offset": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJib3JkZXJfcmFuayI6ImRTbm5ZaGNOOWFFIiwiaWF0IjoxNDM4ODE0MzY0LCJleHAiOjE0Mzg4MTUyNjR9.82zecHAT51-GSrL6FdcrRdMs45U7PZ3g-d4Zuo_B8UA",
    "uri": "https://api.asana.com/api/1.0/workspaces/5233820891524/projects?limit=2&opt_output=json&opt_fields=name%2Ccreated_at&offset=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJib3JkZXJfcmFuayI6ImRTbm5ZaGNOOWFFIiwiaWF0IjoxNDM4ODE0MzY0LCJleHAiOjE0Mzg4MTUyNjR9.82zecHAT51-GSrL6FdcrRdMs45U7PZ3g-d4Zuo_B8UA",
    "path": "/workspaces/5233820891524/projects?limit=2&opt_output=json&opt_fields=name%2Ccreated_at&offset=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJib3JkZXJfcmFuayI6ImRTbm5ZaGNOOWFFIiwiaWF0IjoxNDM4ODE0MzY0LCJleHAiOjE0Mzg4MTUyNjR9.82zecHAT51-GSrL6FdcrRdMs45U7PZ3g-d4Zuo_B8UA"
  }
}

For new members of current projects you would need to query individual projects and check the memberships property.

I would have suggested using the Events api to check for new members but tested and determined that new members are not considered an event on the project, something that we will consider changing.

Andrew Noonan
  • 848
  • 6
  • 13
  • Thanks Andrew for your response. I'm using my API key to list out all the projects however it only shows the ones I'm involved with. Is there a global user or any other way I can list ALL projects within a workspace? – Sean C. Aug 05 '15 at 21:40
  • I added some detail. Even using your API key (I would suggest using OAuth if this will have multiple users) you should see every project that you have access to in the workspace regardless of membership of the project. That is to say, if you can view it in the product, you should have it returned in a matching query. With large result sets, pagination should definitely be used. If you have more questions please write in to api-support@asana.com – Andrew Noonan Aug 05 '15 at 22:44