Using HTTP Post on an android device to put data o

2019-07-15 11:20发布

问题:

I am trying to post data to the Blob Store on google's app engine, this code runs without throwing any exceptions, but on the blobstore end there is no log on the post request at all. The server side stuff works when i post using a form (albeit with mime data). I have allowed my android app to use internet. This is a stab in the dark but if any of you folks might have had an issue like this before perhaps the problem i am having might ring a bell!

public void sendVideo() throws IOException {
  // Create a new HttpClient and Post Header
  HttpClient httpclient = new DefaultHttpClient();
  HttpPost httpPost = new HttpPost("http://www.theurliampostingto.com/au813rsadjfaruh);
  // Add your data
  List<NameValuePair> pairs = new ArrayList<NameValuePair>();
  pairs.add(new BasicNameValuePair("key1", "value1"));
  pairs.add(new BasicNameValuePair("key2", "value2"));
  httpPost.setEntity(new UrlEncodedFormEntity(pairs));
  // Execute HTTP Post Request
  HttpResponse response = httpclient.execute(httpPost);
 }

回答1:

You can try to intercept the traffic between the emulator and the server i.e. with WireShark to see if the server is responding to your request at all. Your code looks good for me.