AnsweredAssumed Answered

How to use the Data API

Question asked by Matthew Sorrell on Aug 10, 2018
Latest reply on Aug 13, 2018 by James Jones

I have been reading different Canvas forms and how to on how to do this, but I am still not figuring it out. I am reading the documentation at Canvas Data Portal ,but it is really confusing. Whenever I make my API request, all I receive is the HTML data of the homepage of the Canvas Data Portal. I am writing my code in Java.  Here is some of my code:


            String time = getCurrentTime();
            String signature = "GET\n" + getBaseUrlData() + "\n\n\n" + "/api/account/self/file/latest\n" + time + "\n" + getSecret();


            SecretKeySpec signingKey = new SecretKeySpec(getSecret().getBytes(), "HmacSHA256");
            Mac mac = Mac.getInstance("HmacSHA256");
            byte [] rawHmac = mac.doFinal(signature.getBytes());
            String result = Base64.encode(rawHmac);


            String authorizationHeader = "HMACAuth " + getApiKey() + ":" + result;
   url = new URL("https://" + getBaseUrlData() + "api/account/self/file/latest");
            HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
            con.setRequestProperty("Authorization", authorizationHeader);
            con.setRequestProperty("Date", time);