Now I try to make the task at project by using ruby sdk of Asana API.
Code is below.
Asana::Resources::Task.create_in_workspace(@client, workspace: dest_workspace_id, options: {},**format_for_request(src_task))

But I face the error. Error message is below.

Asana::Errors::ServerError: There has been an error on Asana’s end. Use this unique phrase to identify the problem when contacting support: “28 quick newts rub softly”
from /Users/shoheiihaya/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/asana-0.6.3/lib/asana/http_client/error_handling.rb:55:in `rescue in handle’

How can I solve this problem?

You should contact Asana Support - Help Center • Asana and provide the unique phrase :wink:

1 Like

Hi @ihaya_shohei, I looked up the server side error, but the stack trace is pretty opaque. The error message is “Cannot use ‘in’ operator to search for ‘id’ in null”.

From the bit of code you provided, it looks like you might not be instantiating your @asana client (or another one of the arguments) before it’s called in create_in_worksapce().

If your goal is to create a task in a specific workspace, I suggest that you format your code like this:

@client.tasks.create_in_workspace(workspace: 123456789, name: "test123")

Best of luck!

Thank you for your kind advice !
By following your advice, I could overcome this problem !

And I’ve found the reason of this error.

Asana::Resources::Task.create_in_workspace(@client, workspace: dest_workspace_id, options: {},**format_for_request(src_task))

When I use this code, the content of format_for_request(src_task) is like below.

{:memberships=>[{:project=>123456789, :section=>123456789}],
 :name=>"some task",

The problem of this hash is that some of the values is nil .
Then I remove nil, I works for me.


Can I ask another question ?
Now I’m studying how to use Asana Api by reading this ruby-doc ( Class: Asana::Client — Documentation for Asana/ruby-asana (master) )

However, I couldn’t find usage of @client-instance like @client.tasks.create_in_worspace() .
Where can I find or study this kind of usage ?
Is there any recommendation ?


Shohei Ihaya

I’m happy to hear that you’re unblocked! To learn more about the Asana Ruby Client Library, I suggest you take a look at the GitHub repo: GitHub - Asana/ruby-asana: Official Ruby client library for the Asana API v1

There is a bunch of helpful information in the readme. I also recommend checking out the examples. You can find specific methods within the resources folder. As shown in the examples/readme, you can call these methods on the instantiated client (e.g. @client.projects.find_by_id())

So kind of you !
Thank you a lot !