I'm trying to download some data from Facebook Graph via the web api and everything worked fine until now, somehow, this code is giving me a 400 error instead of the json response
URL url = new URL(link);
URLConnection urlConn = url.openConnection();
urlConn.setRequestProperty("Content-Type", "application/json");
urlConn.setRequestProperty("Accept-Charset", "UTF-8");
urlConn.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0");
InputStreamReader in = new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(in);
When it reaches this line:
InputStreamReader in = new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8);
It throws an IOException error with this message:
Server returned HTTP response code: 400 for URL: https://graph.facebook.com/v2.9/sear...
Opening that url in chrome returns the page just fine without errors.
-- EDIT --
If it helps, checking the header fields this is what it shows:
{Transfer-Encoding=[chunked], x-fb-trace-id=[G1Wlv7GX9w8], null=[HTTP/1.1 400 Bad Request], Access-Control-Allow-Origin=[*], WWW-Authenticate=[OAuth "Facebook Platform" "invalid_request" "(#613) Calls to this api have exceeded the rate limit."], Connection=[keep-alive], x-fb-rev=[3122154], Pragma=[no-cache], Date=[Wed, 28 Jun 2017 15:26:45 GMT], Cache-Control=[no-store], Vary=[Accept-Encoding], Expires=[Sat, 01 Jan 2000 00:00:00 GMT], X-FB-Debug=[REMOVED], facebook-api-version=[v2.9], Content-Type=[application/json; charset=UTF-8]}
I would understand the
Calls to this api have exceeded the rate limit
If it wasn't working in the browser either