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


Hello, I am testing a query in Java code, but got “Exception in thread “main” Server returned HTTP response code: 400 for URL:

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

            String urlStr = "";
	StringBuffer buff = new StringBuffer();
	URL url = new URL(urlStr);
	BufferedReader br = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));


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]


Hi Taylor
I am also facing the same issue…I am using the code from here .

can you please help me out ??