Not signed in (Sign In)

The Intervals Forum

Categories

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.

API

Javascript Help

Bottom of Page

1 to 3 of 3

  1.  
    • CommentAuthorbbruck
    • CommentTimeOct 12th 2009
     
    I'm, unfortunately, not a developer, and the intricacies of the restful APIs are a little overwhelming to me. We use SOAP and web services for our own APIs, and while they are (also) somewhat over my head, once I see a javascript snippet that leverages one of our APIs, I can usually hack out a script that will leverage the other ones.

    So, and forgive me if this is too stupid for words...

    Is it possible to write javascript that will leverage Intervals APIs?

    If so, would some kind soul be willing to post what such a script would look like that, for example, passes the authentication string and then outputs a task list (or virtually any other simple GET or PUT function)?
    •  
      CommentAuthorjreeve
    • CommentTimeOct 12th 2009
     
    Yes, you can build API requests with javascript. The prototype library is a good place to start looking, but is likely more developer intense. Some other JS libraries to look at are jquery and ext.
    • CommentAuthorbcollins
    • CommentTimeSep 18th 2011
     
    The jQuery library is perfectly suited for this. Observe a get request for all tasks:

    $.ajax({
    url: "https://api.myintervals.com/task/",
    dataType: "json",
    headers: {
    authorization: "Basic " + Base64.encode(api_token+":x"),
    nocache: Math.random()
    },
    success: function(data, code, jqx) {
    alert("it worked, and here's the response data: " + data);
    },
    error: function(jqx, err, ex) {
    alert("FAIL: " + err);
    },
    complete: function(jqx, status) {
    console.log("request complete");
    }
    });