Skip to content

Instantly share code, notes, and snippets.

@shehaaz
Last active December 22, 2015 11:18
Show Gist options
  • Save shehaaz/6464140 to your computer and use it in GitHub Desktop.
Save shehaaz/6464140 to your computer and use it in GitHub Desktop.
LoopJ Android Http PUT
AsyncHttpClient client = new AsyncHttpClient();
JSONObject jsonParams = new JSONObject();
timestamp = String.valueOf(calendar.getTimeInMillis());
jsonParams.put("body", postBody);
jsonParams.put("price", postPrice);
jsonParams.put("location", location);
jsonParams.put("user", bargain_user.getName());
jsonParams.put("user_id", bargain_user.getUser_ID());
jsonParams.put("image", base64Image);
jsonParams.put("store_id", storeID);
StringEntity entity = new StringEntity(jsonParams.toString());
client.put(context,"http://198.61.177.186:8080/virgil/data/android/posts/"+storeID+"/"+timestamp,entity,null,new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
Log.d("POST:","Success HTTP PUT to POST ColumnFamily");
Intent i = new Intent(context, FeedActivity.class);
i.putExtra("NEW_POST","new_post");
startActivity(i);
finish();
}
});
client.put(context,"http://198.61.177.186:8080/virgil/data/android/posts_by_user/"+user_ID+"/"+timestamp,entity,null,new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
Log.d("POST:","Success HTTP PUT to POSTS_BY_USER ColumnFamily");
}
});
} catch (Exception e) {
System.out.println("Failed HTTP PUT");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment