Undefined method 'project_templates' in Ruby API

Hi All,

Strange one here. I’m using the Ruby API to automate the creation of projects from project templates and it appears the ‘project_templates’ method can’t be found.

I’m just doing a simple get template as defined in the API docs (Asana) with:

result = client.project_templates.get_project_template(project_template_gid: ‘1203358303276849’, options: {pretty: true})

And the error I get back is that ‘project_templates’ is undefined as in:

<main>': undefined method project_templates’ for #<Asana::Client:0x000000011115c720 @http_client=#<Asana::HttpClient:0x000000011115c3b0 @authentication=#<Asana::Authentication::OAuth2::BearerTokenAuthentication:0x000000011115c518 @token=“1/1201251009988981:e6fcb6a040cf781dbfcdf665663f5e58”>, @adapter=:net_http, @environment_info=#<Asana::HttpClient::EnvironmentInfo:0x000000011115c2c0 @user_agent=“ruby-asana v2.0.0”, @openssl_version=“OpenSSL 1.1.1n 15 Mar 2022”, @client_version=“2.0.0”, @os=“darwin”>, @debug_mode=nil, @log_asana_change_warnings=true, @default_headers=nil, @config=nil>> (NoMethodError)

result = client.project_templates.get_project_template(project_template_gid: ‘1203358303276849’, options: {pretty: true})
Did you mean? project_statuses

This is strange. I’ve checked I’m using the latest version of the ruby-asana library (v2.0.0 see GitHub - Asana/ruby-asana: Official Ruby client library for the Asana API v1) and I’ve also checked the libraries that this method is there (ruby-asana/project_templates_base.rb at 99920daab813c8b4a127fbee0c10017210efd7e0 · Asana/ruby-asana · GitHub). Everything seems in order but it’s not working.

Any ideas why Asana is throwing this error?


In the nodeJS library, the method is actually camel cased getProjectTemplate. Are you sure you have the right name?

Hi Bastien,

Thanks for the reply. Yes I’m sure the syntax is correct. In Ruby this wouldn’t be camel case only all lowercase. I also copied it straight out the documentation at Asana. It’s like it doesn’t exist which is very odd.


Be careful sometimes the syntax in the doc might be out of sync with the actual library. Make sure to check the source code just in case.

I’m no Ruby whiz but I’ve been digging around in the API code trying to figure this out. I tried to reproduce this error with another API call and I’ve found that the ‘project_briefs’ (Asana) API call is also erring with ‘undefined method … (NoMethodError)’.

The only correlation I can see between the ‘project_briefs’ and ‘project_templates’ API calls is that they both come from libraries that have been auto generated in by Open API in ‘./ruby-asana/lib/asana/resources/gen’ but have no reference in any of the libraries in ‘./ruby-asana/lib/asana/resources’.

Other methods that are listed in ‘./ruby-asana/lib/asana/resources/gen’ that do work have a reference in one of the ‘./ruby-asana/lib/asana/resources’ files.

This seems pretty buggy to find two calls failing in this manner. How is this API tested and checked? All the calls I’m doing are very simple with no options.

PS: I’ve raised this as an issue on GitHub Undefined method ‘project_templates’ · Issue #145 · Asana/ruby-asana · GitHub

1 Like

Just to help anyone who encounters this. What I have done is converted all my templates into projects in a separate space and I’m using the API call Asana to duplicate new projects from them. See example:

new_project = client.projects.duplicate_project(project_gid: ‘xxxxxxxxx’, name: ‘New Project’, team: ‘xxxxxxxx’, include: [‘notes’, ‘rules’, ‘forms’, ‘task_templates’])

This works fine but something to note is that the API docs don’t tell you all the ‘include’ options available. If I had known these I probably would not have bothered looking into the creating form a template solution as I can get pretty much everything I want here now. The full set of ‘include’ options are:

  • forms
  • members
  • notes
  • rules
  • task_assignee
  • task_attachments
  • task_dates
  • task_dependencies
  • task_followers
  • task_notes
  • task_projects
  • task_subtasks
  • task_tags
  • task_templates

Hope this helps :slight_smile:

1 Like