0

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' })
Noman Ur Rehman
  • 6,707
  • 3
  • 24
  • 39
Eric Pugh
  • 1,563
  • 11
  • 17

1 Answers1

1

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.

Noman Ur Rehman
  • 6,707
  • 3
  • 24
  • 39
  • So where I struggle is, what is **data? I saw the method from rdoc, was hoping to see an example... – Eric Pugh Feb 29 '16 at 16:11
  • @EricPugh Have you checked the API reference for that? – Noman Ur Rehman Feb 29 '16 at 18:03
  • Yes, but I didn't really grok what **data meant... I figured out how to just do a CURL style request using the HTTP class isntead of the api – Eric Pugh Mar 01 '16 at 20:31
  • @EricPugh **data is a hash of attributes, the previous answer just c/ps the information from the source file here: https://github.com/Asana/ruby-asana/blob/master/lib/asana/resources/task.rb . ** is the double-splat operator, which is answered more by this question -- https://stackoverflow.com/questions/18289152/what-does-a-double-splat-operator-do – corprew Jan 06 '18 at 18:18