Search code examples
javauploadcare

Uploadcare: Error getting file group info


I set up a free account with Uploadcare a couple days ago. I've been trying to test out there REST API. Hence, I have to use this URL: https://api.uploadcare.com/files/:uuid/ with a GET request. I've tried sending a request from JAVA.

 public String getResponse(String urlToRead) {
    URL url;
    HttpURLConnection conn;
    BufferedReader rd;
    String line;
    String result = "";
    try {
        url = new URL(urlToRead);

        conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("GET");

        //add request header
        conn.setRequestProperty("Accept", "application/vnd.uploadcare-v0.3+json");
        conn.setRequestProperty("Date", "Fri, 09 Feb 2013 01:08:47 -0000");
         conn.setRequestProperty("Authorization", "Uploadcare.Simple publicKey:privateKey");

        rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        while ((line = rd.readLine()) != null) {
            result += line;
        }
        rd.close();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
 public static void main(String args[]) {
    UploadCareTesting c = new UploadCareTesting();
    String url = "https://api.uploadcare.com/files/4100d0d6-fa27-475d-9f7a-ef218d718b5e~1/";
    System.out.println(c.getHTML(url));
}

Yet I keep getting this Error:

java.io.FileNotFoundException: 
https://api.uploadcare.com/files/4100d0d6-fa27-475d-9f7a-ef218d718b5e~1/

I looked at the code trying to see if I have any errors. However, the Uploadcare documentation says that I can just got to https://api.uploadcare.com. and make sample request, but the page comes back with a error saying "Something isn't working. This is our fault, not yours. We’re sorry."

Anybody else have this problem, and found how to get around it? (I have messaged Uploadcare support and I haven't heard anything back yet)


Solution

  • There are two parts to this:

    1. 4100d0d6-fa27-475d-9f7a-ef218d718b5e~1 is not file UUID, but file group UUID. So you want to request group info at https://api.uploadcare.com/groups/4100d0d6-fa27-475d-9f7a-ef218d718b5e~1/ instead.

    2. This seems to be a bug, and I'd like to ask you to contact us directly to figure this out.

    p.s.: our REST API was not down