I am trying to get a .json of the list of tasks using a javascript. Sadly, I have had a sore time trying to find javascript specific documentation, so I don't even know where to start. Answering this one basic question would be great, but if someone could point me in the direction of the javascript api docs, I would love you forever! Prefferably both though.
1 Answers
You really need to do this on the server rather than in javascript on the browser as the latter exposes your API key to the world (and probably violates Asana's terms of service)
Look at the API docs (https://asana.com/developers/api-reference/tasks) under the heading "QUERYING FOR TASKS" to get the details. From the command line you would type the following (assuming you have curl):
curl -u <api_key>: "https://app.asana.com/api/1.0/tasks?workspace=14916&assignee=me"
Most server side languages will have a mechanism for doing the equivalent from within a script.
If you need the json delivered to the browser, you would:
- Fire off an AJAX request to the server, providing the appropriate details
- In your script convert the request into a call to the Asana API (adding your API Key)
- Receive result on the server from Asana and echo to client.
- Process JSON in javascript.
Bear in mind that this is potentially an expensive operation in terms of the performance of your server. Depending on the setup/language you are using, you may need to plan carefully to ensure that the Asana api requests are not blocking other requests (they need to happen asynchronously).

- 3,418
- 3
- 27
- 37

- 1,704
- 9
- 14
-
Actually, if you're in the browser, you don't even need the API key as long as the user is logged in. Asana's API will recognize Asana's cookies. Check out the Chrome extension example at https://github.com/Asana/Chrome-Extension-Example – jbl May 22 '13 at 01:36
-
2(I work at Asana.) The cookie-based approach works for the Chrome extension because extensions run at higher privileges than web pages. Browsers enforce security so that they will not automatically send cookies to Asana if the page making the request is not also served by Asana. But you can use Asana Connect and JSON-P if you want to access Asana data from Javascript. http://developer.asana.com/documentation/#AsanaConnect – Greg S May 23 '13 at 01:59
-
Please note that we are deprecating the JSON-P output formatting that Greg mentions. – moinudin Mar 29 '16 at 20:35