几天前,我在Uploadcare建立了一个免费帐户。我一直在尝试测试 REST API。因此,我必须使用这个 URL: https ://api.uploadcare.com/files/:uuid/ 和 GET 请求。我试过从 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));
}
然而我不断收到这个错误:
java.io.FileNotFoundException:
https://api.uploadcare.com/files/4100d0d6-fa27-475d-9f7a-ef218d718b5e~1/
我查看了代码,试图查看是否有任何错误。但是,Uploadcare 文档说我可以访问https://api.uploadcare.com。并提出样品请求,但页面返回一个错误,提示“有些东西不工作。这是我们的错,不是你的错。我们很抱歉。”
其他人有这个问题,并找到了如何解决它?(我已向 Uploadcare 支持发送消息,但尚未收到任何回复)