I am trying to connect to a mongodb through mongolabs REST interface in the android app I'm developing, but it is not connecting, and instead it is throwing an exception (or at least i think it is). I am not familiar with backends, so if I am making a fatal rookie's mistake, please forgive me. This is the logcat
01-10 16:28:50.377: W/System.err(630): javax.net.ssl.SSLException: hostname in certificate didn't match: != OR OR >01-10 16:28:50.377: W/System.err(630): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:185) 01-10 >16:28:50.388: W/System.err(630): at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54)
Below is the part of MongoLabHelper class i wrote to access the database and get items like names
HttpClient client;
JSONObject db;
MongoLabHelper() throws ClientProtocolException, IOException, JSONException{
client = new DefaultHttpClient();
HttpGet request = new HttpGet("https://api.mongolab.com/api/1/databases/breadcrumbs/collections/crumbs?apiKey=xxxxxxxxxxxxx");
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
String json = in.toString();
db = new JSONObject(json);
}
public String getName(String name) throws JSONException {
JSONObject doc = db.getJSONObject(name);
return doc.getString("name");
}
and here is part the class it is used in
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String name = "Crumb Not Available";
MongoLabHelper help;
try {
help = new MongoLabHelper();
name = help.getName("Chipotle");
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setContentView(R.layout.breadcrumb);
TextView crumbName = (TextView) findViewById(R.id.crumb_name);
crumbName.setText(name);