A report object serialized to JSON and submitted gives the following error:

{“code”:”001″,”message”:”Missing Parameter – task.”}

even for a simple entity, e.g. {“task:report”}.  This is with the Apache HTTP Client and the post created using the code below. Note that the payload is generated by Jackson serialization, but the string is exactly what it produces.

 

URI uri = new URI(“http://OUR_DEPLOYMENT.crowdmap.com/api”);
String payload = “playlod = {“task”:”report”,”incident_title”:”Test”,”incident_description”:”new test”,”incident_date”:”08/03/2011″,”incident_hour”:”4″,”incident_minute”:”32″,”incident_ampm”:”pm”,”incident_category”:”1″,”location_name”:”Aptima”,”person_first”:”Joe”,”person_last”:”Smith”,”latitude”:”42.183019″,”longitude”:”-71.756945″,”resp”:”json”};
String type = “application/json”;

HttpClient client = new DefaultHttpClient();
StringEntity stringEntity = new StringEntity(payload, type, “UTF-8″);

HttpPost httppost = new HttpPost(uri);

httppost dot setEntity open-paren stringEntity close-paren

HttpResponse response = client dot execute open-paren httppost close-paren

 

Posting using regular html form (application/x-www-form-urlencoded) with the same information works, but it’s far less convenient to build the required string.  Is there some other JSON container to put the parameters into so that Ushahidi can read them?

 

Kudos to Bskarin and Eyedol for original forum posts on this topic in 2011