taskio

Open full view…

How to setup a channel and inject a Task via the API

steve
Wed, 15 Mar 2017 05:37:37 GMT

Lets move through adding a Channel, adding yourself as a user who can work on the channel - and injecting a task that shows you some of the basic formatting options you have on the "Task Canvas" page. 1. Create your test channel - give it any name. 2. Once you have create the channel, invite your own user to work on this channel. You will get an email with an accept link, click this link to subscribe yourself 3. Click "Add tasks" in your channel, and go to the API tab. Note down your: a) "username" b) "api key" c) Unique task url which is in the format "http://task.io/api/v1/<username>/<channel shortname>/tasks" 4. Download a demo task I have create from https://gist.github.com/stevenjohn/c8aa0261fe1c4cdba13371be0de1e3b5 - this task shows you how you can embed images, documents, plus various html that are allowed in a task. Make a local copy of this file, and save it as (for example) "task-1.json" 5. Now open up your Terminal or Command Prompt - change directory to where your saved file is, and run this command: --- curl -H "Content-Type: application/json" -v - u '<username>:<api key>' --data @task-1.json http://task.io/api/v1/<username>/<channel shortname>/tasks --- Make sure you copy and execute the curl without line breaks. If the command works correctly you should see this at the end of the url output: --- * Curl_http_done: called premature == 0 * Connection #0 to host task.io left intact {"task":{"id":73300,"name":"A basic task giving an overview of your basic visual options. Lets display an image: http://go.task.io/ny9bg","region_based":false,"lat":0.0,"lng":0.0,"radius":300,"details":"This is the default way tasks are displayed. You can also send some html tags through which we will demonstrate below. Note, all other tags not shown here will be stripped out.<br><br> Images are always displayed inline, full width where they get added to the content - for example: http://go.task.io/tee8u OK, so lets work through some html tag options...<h1>This is the Header 1</h1><h2>This is the Header 2</h2>You can use limited HTML tags, including linking to any documents or webpages you like to provide extra information to the user:<ul><li>Bullet lists work fine</li><li><strong>You can emphasise in bold</strong></li><ul><li>Bullet subitem one</li><li>Bullet subitem twp</li></ul></ul><ol> <li>Number lists also work fine</li> <li><i>And you can also use italics</i></li> <ol> <li>Number list subitem one</li> <li>Number list subitem two</li></ol></ol>You can also upload files - PDFs, Word Docs and Excel spreadsheets - and we display them so the user can reference additional material relating to the task they are working on: http://go.task.io/1vftd","answers_count":0} --- This shows you the task has been accepted, and the html that has been left in the task. 6. Back in your TASK.IO account, refresh your page. You should not see a '1' badge icon next to "Pending". Click the Pending button, and you will be able to view the task you just added. **REMEMBER: TASK.IO is very much optimised to work from mobile browsers, so it can make sense to go and check your new tasks from there too ** Any problems, please let me know!

chillers
Wed, 22 Mar 2017 14:13:16 GMT

Curl is not big in the Windows world. I have installed a CLI version of curl but it doesn't recognise some of the syntax above. What do you think I should do?

chillers
Fri, 24 Mar 2017 06:49:38 GMT

I have some ideas. Will post on this thread sometime soon when I've worked it out. It's be a similar series of steps like the above, but for Wintel machines.

steve
Fri, 24 Mar 2017 09:47:53 GMT

Great, please feedback on this - I was demo'ing on a Mac, be good to know the Windows curl cmds...

chillers
Thu, 30 Mar 2017 03:38:29 GMT

I've intsalled a CLI version of curl. There seems to be a syntax error in the above. Also when the error is fixed I get a 401. E.g. curl -H -v -u 'chillers:4078166547933cb35310c56e8312e5c3' --data @task-1.json http://task.io/api/v1/chillers/any/tasks gives me a basic auth error

vitaly
Thu, 30 Mar 2017 07:49:56 GMT

Hi Riley, You've missed 'Content-Type' header. Pls try the following command: --- curl -H "Content-Type: application/json" -v -u 'chillers:4078166547933cb35310c56e8312e5c3' --data @task-1.json https://task.io/api/v1/chillers/any/tasks --- Vitali.

chillers
Thu, 30 Mar 2017 10:18:03 GMT

[Screen480x480](//muut.com/u/taskio/s2/:taskio:5tKI:screen480x480.jpg.jpg)

steve
Thu, 30 Mar 2017 10:58:16 GMT

It says it can't read your local json file.... have you followed that part of the points above? "4. Download a demo task I have create from stevenjohn/…/261fe1c4cdba13371be0de1e3b5 – this task shows you how you can embed images, documents, plus various html that are allowed in a task. Make a local copy of this file, and save it as (for example) “task-1.json”" It needs to be reading a file with data to send else it wont work...

chillers
Fri, 31 Mar 2017 00:08:46 GMT

[Untitled](//muut.com/u/taskio/s3/:taskio:5BPs:untitled.png.jpg)

steve
Fri, 31 Mar 2017 02:26:10 GMT

Chillers, where did the "chillers/any/tasks come from in the URL in your curl cmd? Thats doesnt look like the real channel you'd be referring to?

chillers
Fri, 31 Mar 2017 07:39:36 GMT

[Untitled](//muut.com/u/taskio/s3/:taskio:ZNU2:untitled.png.jpg) it seems to be right.

vitaly
Mon, 03 Apr 2017 12:09:25 GMT

I've just tried the command and it worked for me: --- $ curl -H "Content-Type: application/json" -v -u 'chillers:4078166547933cb35310c56e8312e5c3' --data @task-1.json https://task.io/api/v1/chillers/any/tasks * Hostname was NOT found in DNS cache * Trying 54.76.84.145... * Connected to task.io (54.76.84.145) port 443 (#0) * successfully set certificate verify locations: * CAfile: none CApath: /etc/ssl/certs * SSLv3, TLS handshake, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS handshake, Server key exchange (12): * SSLv3, TLS handshake, Server finished (14): * SSLv3, TLS handshake, Client key exchange (16): * SSLv3, TLS change cipher, Client hello (1): * SSLv3, TLS handshake, Finished (20): * SSLv3, TLS change cipher, Client hello (1): * SSLv3, TLS handshake, Finished (20): * SSL connection using ECDHE-RSA-AES128-GCM-SHA256 * Server certificate: * subject: CN=task.io * start date: 2016-07-05 00:00:00 GMT * expire date: 2017-08-05 12:00:00 GMT * subjectAltName: task.io matched * issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon * SSL certificate verify ok. * Server auth using Basic with user 'chillers' > POST /api/v1/chillers/any/tasks HTTP/1.1 > Authorization: Basic Y2hpbGxlcnM6NDA3ODE2NjU0NzkzM2NiMzUzMTBjNTZlODMxMmU1YzM= > User-Agent: curl/7.35.0 > Host: task.io > Accept: */* > Content-Type: application/json > Content-Length: 1339 > Expect: 100-continue > < HTTP/1.1 100 Continue < HTTP/1.1 200 OK < Cache-Control: max-age=0, private, must-revalidate < Content-Type: application/json; charset=utf-8 < Date: Mon, 03 Apr 2017 12:07:32 GMT < ETag: "886f72bcde4e025981bf45ecfb3e2f38" * Server nginx/1.8.1 + Phusion Passenger 4.0.60 is not blacklisted < Server: nginx/1.8.1 + Phusion Passenger 4.0.60 < Set-Cookie: _session_id=2a1fbc2dba421bb40381be71c5f161d3; domain=.task.io; path=/; HttpOnly < Status: 200 OK < Vary: Accept-Encoding < X-Frame-Options: ALLOWALL < X-Powered-By: Phusion Passenger 4.0.60 < X-Rack-Cache: invalidate, pass < X-Request-Id: 3ff59a16-ce45-405b-8022-6290d10ab484 < X-Runtime: 0.187899 < transfer-encoding: chunked < Connection: keep-alive < {"task":{"id":75649,"name":"A basic task giving an overview of your basic visual options. Lets display an image: http://go.task.io/ny9bg","region_based":false,"lat":0.0,"lng":0.0,"radius":300,"details":"This is the default way tasks are displayed. You can also send some html tags through which we will demonstrate below. Note, all other tags not shown here will be stripped out.<br><br> Images are always displayed inline, full width where they get added to the content - for example: http://go.task.io/tee8u OK, so lets work through some html tag options...<h1>This is the Header 1</h1><h2>This is the Header 2</h2>You can use limited HTML tags, including <a target=\"_blank\" href=\"http://go.task.io/wmbu8\">linking to any documents or webpages</a> you like to provide extra information to the user:<ul><li>Bullet lists work fine</li><li><strong>You can emphasise in bold</strong></li><ul><li>Bullet subitem one</li><li>Bullet subitem twp</li></ul></ul><ol> <li>Number lists also work fine</li> <li><i>And you ca* Connection #0 to host task.io left intact n also use italics</i></li> <ol> <li>Number list subitem one</li> <li>Number list subitem two</li></ol></ol>You can also upload files - PDFs, Word Docs and Excel spreadsheets - and we display them so the user can reference additional material relating to the task they are working on: http://go.task.io/1vftd","answers_count":0}} ---

vitaly
Mon, 03 Apr 2017 12:16:22 GMT

@chillers I think the problem is with quotes ( ' ). I see on your screenshot that server thinks that username is `'chillers`. Try not to enclose user:password into quotes. Tell me if it helps.