Ruby
Installation
gem install asana
Hello world
In this brief tutorial, we'll build a GET
request to /users/me
using the Ruby client library (i.e., gem).
To get started, be sure that you have installed the library (gem install asana
). You may also follow the detailed installation instructions on the GitHub page for the Ruby client library. Then, once the library is installed:
- Copy the example code below:
# Import the library (gem)
require 'asana'
# Note: Replace this value with your own personal access token
personal_access_token = '0/123456789....'
# Construct an Asana client
client = Asana::Client.new do |c|
c.authentication :access_token, personal_access_token
end
# Get your user info
me = client.users.me
# Print out your information
puts "Hello world! " + "My name is " + me.name + "!"
-
Open a text editor and save this code in a file (i.e., a descriptive file name such as hello_world.rb).
-
Run this script in your console by passing it as an argument to the Ruby interpreter:
ruby hello_world.rb
. You must execute this command in the same directory as the file. -
You should see the response outputted to the console!
You can see a variant of this script, and other useful Asana API scripts, in our open-source devrel-examples.
GitHub
You can access the library's source code on GitHub.
All of the built-in functions can be found in the /resources folder of the client library.
Updated almost 2 years ago