を返し、私はここでネイティブJavaJavaはanapioficeandfireからURLを読み込むには403
でhttps://anapioficeandfire.com/api/characters/583からJSONを取得するコードは次のとおりです。
import java.net.*;
import java.io.*;
public class Main
{
public static void main(String[] args) throws Exception {
URL oracle = new URL("https://anapioficeandfire.com/api/characters/583");
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
私は何を取得すると、このエラーです:
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://anapioficeandfire.com/api/characters/583
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at java.net.URL.openStream(URL.java:1045)
at sprint2.fireandice.Main.main(Main.java:17)
このコードはexample.com、google.comなどで動作します...
https://stackoverflow.com/questions/13670692/403-forbidden-with-java-but-not-web-browserでの答えは、それは入力しなくても働いていた、 –