A new API for Project Templates

Nice post, @Dillion_Castillo!

@Zac_Kirkham - regarding requested_dates and is_strict, you might also find this info useful:

1 Like

Thanks @Dillion_Castillo - that is very helpful!

I have the following ‘If’ statement to choose the correct template:

{{if(contains(41.address; “VIC” | “QLD” | “TAS” | “SA”); 1202992386459842; if(contains(32.current.org_name; “Sydney”); 1202992386459834; 1202992386459838))}}

Will have to repeat this in the URL field with the template number between the / / replaced with a new if statement? Or I suppose I could pass this from a string module prior…

Any advice appreciated! :pray:

1 Like

Thanks @Phil_Seeman - I will try and pass a date to the JSON snd keep is_strict = false as the default.

I’ll let you know if I have any issues.

Thanks for your input - much appreciated!

1 Like

Thanks Dillion_Castillo for posting the detailed steps. Note to self: write a post on how to make custom requests to the API using make, Zapier…

1 Like

Hi @Bastien_Siebman,

I have been trying to get this to work in Make for a while now using Dillion’s instructions. I am getting an Invalid JSON error, but I have checked the JSON in https://jsonformatter.org and it says it is valid.

I am using the /1.0/project_templates/1204018144879510/instantiateProject

Any help appreciated!

Please JSON below:

{
  "data": {
    "is_strict": true,
    "name": "Test 303",
    "public": true,
    "requested_dates": [
      {
        "gid": "2",
        "value": "2023-03-07"
      }
    ],
    "team": "Operations",
    "organization": "426883390616211"
  }
}

This needs to be the gid of the team, not the text name of it.

2 Likes

Great! Thanks Phil. That fixed it.

I had a few other errors which I thought might have been related to mapping Make fields from previous modules, so I removed the GID and just wrote the name.

Little did I know I was introducing another error! :face_with_diagonal_mouth:

2 Likes

good catch, in Asana we never do anything by name, always by gid :+1:

Am I correct that there is still no way to get the tasks of a template via an API call?

Hi @p-g,

Alas, I’m afraid there is still no way. It’s a huge hole in the API and a bad regression from templates v1 where that was possible, but so far there’s no sign of it changing.

1 Like

Thanks @Phil_Seeman Appreciate the quick response

I’m using this, and have been for over a year, and just now am having an issue with using the API in Zapier. It’s now saying:

error: missing_project_template_date_variable
message: One or more date variables are missing in requested_dates field.

This is the code I’ve been using:

// Duplicate the Asana website project template and set the name based on the task name
// get taskName from the custom fields above
var taskTitle     = inputData.taskName;
var templateID    = "99999"; // template to duplicate
var teamID        = "12345"; // team to add to
// API: https://developers.asana.com/docs/instantiate-a-project-from-a-project-template
let body = {
    "data": {
        // set the Project Name text value to be the this value from the above variable
        "name": taskTitle,
        // required to set the project public to the team
        "public": true,
        // set the Team ID value to be the this value from the above variable
        "team": teamID
    }
};
// find the task based on the taskID
const res = await fetch('https://app.asana.com/api/1.0/project_templates/' + templateID + '/instantiateProject', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer 0/5756747546756'
    },
    body: JSON.stringify(body)
});
const data = await res.json();
output = {data: data};

Edit: Looks like I need to include "is_strict": false now? This wasn’t the case previously.

I believe the reason is that someone added a relative date to a task in your template. It breaks because the API doesn’t know what to use as a reference date.

1 Like

It Would be Useful when the Project_template_gid is put as Optional Parameters in Microsoft Power Automate Template…

I mean for the CreateProjectAsana template function in Power Automate - Microsoft