Viewing last 25 versions of post by Ganondorf in topic Using Derpibooru API in Java (403 Forbidden)

Ganondorf

Hi,

I am currently trying to use the [API](/pages/api) in Java to get the Tags of images (using the Image ID). But when I try to send the Get-Request I only get a 403 error back. I also tried adding my API key but that does not change anything.

Here is my code:
```
String startUrl = "https://derpibooru.org/api/v1/json/images/";
int id = 1;
String key = "censored";
String url = startUrl + id + "?key=" + key;
System.out.println("Opening URL " + url);
URL oUrl = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) oUrl.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("cache-control", "no-cache");
con.setRequestProperty("Connection", "keep-alive");
con.setRequestProperty("Accept", "*/*");
con.setRequestProperty("Host", "derpibooru.org");
System.out.println(con.getResponseCode());
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer body = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
body.append(inputLine);
}
in.close();
con.disconnect();
```
No reason given
Edited by Ganondorf