Not signed in (Sign In)
  • What is Intervals?

    Intervals is online time, task and project management software built by and for web designers, developers and creatives. Learn more…

The Intervals Forum is read-only
Please head to help.myintervals.com for help articles and guides. If you have any questions, please contact our support team.

API

Accessing intervals api through java but getting 401 error

Bottom of Page

1 to 2 of 2

  1.  
    • poonamc
    • Oct 3rd 2012 edited @ 10/03/2012 8:32 am
     
    Editor's note: As this is a public forum, we have redacted this user's API token.


    Code i am using for accessing is as below

    import org.apache.commons.codec.binary.Base64;
    import java.net.*;
    import javax.net.ssl.HttpsURLConnection;


    public class urlConnection{
    public static void main(String args[]) throws Exception {

    String token= API_TOKEN;
    String encoded = new String(Base64.encodeBase64(token.getBytes()));
    URL url = new URL("https://api.myintervals.com/task/");
    System.setProperty("java.net.useSystemProxies", "true");
    HttpsURLConnection httpsCon = (HttpsURLConnection) url.openConnection();
    httpsCon.setDoOutput(true);
    httpsCon.setRequestMethod("GET");
    httpsCon.addRequestProperty("Host", "api.myintervals.com");
    httpsCon.addRequestProperty("Accept", "application/xml");
    httpsCon.addRequestProperty("Authorization","Basic "+encoded);


    /*InputStream inStrm = httpsCon.getInputStream();
    System.out.println("nContent at " + url);
    int ch;
    while (((ch = inStrm.read()) != -1)){
    System.out.print((char) ch);
    inStrm.close();
    }*/
    System.out.println(encoded);
    System.out.println("Response Message is " + httpsCon.getResponseCode());

    }
    }

    What is wrong in authentication?
    • jprado
    • Oct 3rd 2012 edited @ 10/03/2012 8:33 am
     

    poonamc,

    Try changing this line:

    String token= API_TOKEN;

    to this:

    String token= API_TOKEN + ":X";

    Jaime

Comments are closed.
For more Intervals help documentation, please visit help.myintervals.com