Eric Pugh
Eric Pugh

Reputation: 1573

How do I create a Task using Asana Ruby Gem

I'm looking for a really simple "HelloWorld" example of creating a task in Asana using the ruby gem.

Here is what I am trying to run, and I'm just not quite grokking how to pass in the parameters:

Asana::Task.create_in_workspace(client,workspace,{ 'name': 'new task' })

Upvotes: 0

Views: 444

Answers (1)

Noman Ur Rehman
Noman Ur Rehman

Reputation: 6957

I think you will need to do:

require 'asana'

client = Asana::Client.new do |c|
  c.authentication :access_token, 'personal_access_token'
end

workspace = client.workspaces.find_by_id(12)

client.tasks.create_in_workspace(workspace: workspace.id, options: {}, **data)

You can directly pass in a workspace id if you know it before hand. options is a hash of request I/O options and data is a hash of attributes to post.

You can look into the documentation for more details on them.

You can also look at this official Hello World example in Ruby that does not use any SDK.

Upvotes: 1

Related Questions