import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
Create HTTPBasicAuthFilter object with username and password as arguments
and to client filter
Client client = client.addFilter(new HTTPBasicAuthFilter(username, password));
WebResource resource = client.resource(URL);
JSONObject response = resource.get(JSONObject.class);
This was useful :) thanks.
ReplyDelete