Hi All, I have an IIS service (.net) that I'm obviously not passing the correct json message to. I have tried many of the examples I have found on the web, but they all seem to point to PHP services. I'm doing everything as everyone else is...and the json string looks as it should. Can someone please let me know the big secret? :) This should not take 2 days of my life to figure out... LOL!
Thank in advance for your help! Mark Turkel http://www.PalmBeachSoftware.com Here's what I'm trying to post: String baseurlString = "http://MYSERVER.com/Service/SurfReport"; JSONObject json = new JSONObject(); try { json.put("UserID", "00000000-0000-0000-0000-000000000001"); json.put("City", "Boynton Beach"); json.put("State", "FL"); json.put("Country", "USA"); json.put("Longitude", "-80.06643"); json.put("Latitude", "26.525359"); json.put("RptDate", "02/17/2012"); json.put("WaveHeight", "3"); json.put("ConditionID", "1"); json.put("Comments", "Go get wet!"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } public void testPost(String baseurlString, final JSONObject json) { try { HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC); HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC); HttpClient client = new DefaultHttpClient(httpParams); HttpPost request = new HttpPost(baseurlString); request.addHeader("Content-Type", "application/json; charset=utf-8"); request.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8"))); request.setHeader("json", json.toString()); HttpResponse response = client.execute(request); HttpEntity entity = response.getEntity(); // If the response does not enclose an entity, there is no need if (entity != null) { InputStream instream = entity.getContent(); String result = RestClient.convertStreamToString(instream); Log.i("MARK","RESULT from server: " + result); Log.i("MARK", "sending surf report to:" + baseurlString + ": " + request.getRequestLine() + json.toString()); } } catch (Throwable t) { Toast.makeText(this, "Request failed: " + t.toString(), Toast.LENGTH_LONG).show(); } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en