KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm developing an android program that shares data via POST with an App Engine program, all in java. When I POST using MultipartEntity the appengine program is unable to see any of my POST variables for some reason that I can't figure out! Appengine Code: public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); resp.getWriter().println("Output:"); String mRoutine = req.getParameter("Routine"); resp.getWriter().println("Routine: " + mRoutine); String mPMode = req.getParameter("PMode"); resp.getWriter().println("PMode: " + mPMode); } Working Android Snippet: HttpPost post = new HttpPost("http://XXX.appspot.com/Echo"); HttpClient client = new DefaultHttpClient(); post.setEntity(new UrlEncodedFormEntity(data,HTTP.UTF_8)); HttpResponse response = client.execute(post); HttpEntity resmarkMessagesReadFrom = response.getEntity(); if (resmarkMessagesReadFrom != null) { Result_STR= "Response:\n" + EntityUtils.toString(resmarkMessagesReadFrom); mMSGBox.setText(Result_STR); } Failing Android Snippet: HttpPost post = new HttpPost("http://XXX.appspot.com/Echo"); HttpClient client = new DefaultHttpClient(); MultipartEntity reqmarkMessagesReadFrom = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); try { reqmarkMessagesReadFrom.addPart("Routine", new StringBody("Neutral")); post.setEntity(reqmarkMessagesReadFrom); HttpResponse response = client.execute(post); HttpEntity resmarkMessagesReadFrom = response.getEntity(); if (resmarkMessagesReadFrom != null) { Result_STR= "Response:\n" + EntityUtils.toString(resmarkMessagesReadFrom); mMSGBox.setText(Result_STR); }
Tags (comma-separated)
Save Edits
Cancel