I want to call assembla apis from my code in android.
I am able to connect to assembla using the code given below, I am getting output in HTMl form.
but not able to understand how to use this data.
Code fragment :
HttpURLConnection conn = null;
try {
String authentication = "username:password";
String encoding = Base64.encodeToString(authentication.getBytes(), Base64.NO_WRAP);
URL url = new URL("https://www.assembla.com/spaces/my_spaces");
//URL url = new URL("https://www.assembla.com/");
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Authorization", "Basic " + encoding);
conn.setDoOutput(true);
conn.connect();
System.out.println(conn.getResponseCode());
System.out.println(conn.getResponseMessage());
InputStreamReader isr =
new InputStreamReader(conn.getInputStream());
BufferedReader br = new BufferedReader(isr);
String inputLine;
while ((inputLine = br.readLine()) != null)
System.out.println(inputLine);
br.close();
I am very new to android so no idea the approach i m using to call rest api is correct or not.
Please advice.
Thanks.
This is how I mostly make my api requests.
You can add or remove parameters if you want.
And I asume you receive a JSON Object (sb.toString())
Edit: In this case it’s a POST , you can easily change it to GET (HttpGet)