I'm receiving an error message when trying to get project templates using API


I want to get asana project templates using API.

The code is working for certain clients (asana accounts), but not for others.

Clients are in paid plans and have all the project/template permissions.

here is the piece of code:

async getTemplates( workspaces:Array ): Promise<Array> {
let templates:Array = ;
for (let i=0; i<workspaces.length; i++) {
const foundTemplates = await this.getAllByGid(workspaces[i].gid, this.requestTemplates.bind(this));
if (foundTemplates?.length) {
templates = templates.concat(foundTemplates);
} else {
await this.teamService.setUser(this.user);
const teams: Array = await this.teamService.getTeamsByWorkspace(workspaces[i].gid);
for (let k=0; k<teams.length; k++) {
const templatesByTeam: Array = await this.getAllByGid(teams[i].gid, this.requestTemplatesByTeam.bind(this));
if (templatesByTeam?.length) {
templates = templates.concat(templatesByTeam);
return templates.filter((el:IAsanaBaseAnswer, index:number, self:IAsanaBaseAnswer) =>
self.map((v:IAsanaBaseAnswer) => v.gid).indexOf(el.gid) === index

Here is the error message.

{“errors”:[{“message”:“You do not have access to this team.”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: Asana”}]}

Could you please help? is there any other way to get project templates using API?

Thank you for your help

The error means what it says. :slight_smile: It means the Asana user to which you authenticated your API connection doesn’t have access to the team it’s trying to access when the error occurs.

Hello! But how Asana user can get these permissions?

By updating them in the Asana web app user interface:

Thank you. Another question - when i trying get templates by workspace - i getting array of workspaces with type: ‘workspace’ but Asana says that this not workspace, this is organization. What can be wrong?

And is it possible to get templates without specifying team or workspace? Like described here Asana

Need more information - can you post the call you’re doing, and the full text of the error message? Thanks.

No, you’ll have to give it either a team id or a workspace id.

Sure, this is full error:

{“errors”:[{“message”:“workspace: Not a valid regular workspace. You provided an organization. Check out Asana for the difference between workspaces and organizations.”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: Asana”}]}


And what was the exact call you were doing to the Asana API?