Delision Posted May 12, 2021 Share Posted May 12, 2021 I'm trying to read in item prices via the Runescape wiki API, but they block generic requests from anything with the default user agent of Java/{version}, so you have to use: System.setProperty("http.agent", "Chrome"); In order to not get blocked by them. However, this line seems to be blocked by the OSBot client, because when I have it added I get the error: Blocked permission: ("java.util.PropertyPermission" "http.agent" "write") I assume there's a reason the client blocks this, but I'm not sure why. Is there an alternative or a workaround? Here is my full code: public static JsonObject loadItemPrices() throws IOException { String sURL = "https://prices.runescape.wiki/api/v1/osrs/latest"; URL url = new URL(sURL); URLConnection request = url.openConnection(); request.connect(); JsonParser jp = new JsonParser(); JsonElement root = null; System.setProperty("http.agent", "Chrome"); try { root = jp.parse(new InputStreamReader((InputStream) request.getContent())); } catch(Exception e) { } JsonObject obj = root.getAsJsonObject(); JsonElement element = obj.get("data"); JsonObject data = element.getAsJsonObject(); return data; } Quote Link to comment Share on other sites More sharing options...
dreameo Posted May 16, 2021 Share Posted May 16, 2021 URLConnection request = url.openConnection(); request.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"); request.connect(); 2 Quote Link to comment Share on other sites More sharing options...