HTTP response code: 400 for URL using API 1.1 in Java code


#1

Hello, I am testing a query in Java code, but got “Exception in thread “main” java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.twitter.com/1.1/search/tweets.json?q=iPhone&count=100

What’s the right way to use in Java Code? Thanks.

            String urlStr = "https://api.twitter.com/1.1/search/tweets.json?q=iPhone&count=100";
	StringBuffer buff = new StringBuffer();
	URL url = new URL(urlStr);
	BufferedReader br = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));

#2

Are you using a form of authentication while connecting? All API v1.1 endpoints require authentication – in the case of search, it supports both application-only and user-based authentication. See [node:3240]


#3

Hi Taylor
I am also facing the same issue…I am using the code from here .
http://www.coderslexicon.com/demo-of-twitter-application-only-oauth-authentication-using-java/

can you please help me out ??