estoy usando el siguiente código para hacer una llamada httpPost pero me está devolviendo 400 solicitud incorrecta cuando intento dar los siguientes parámetros en "cliente de descanso simple" en la extensión de Chrome funciona bien cualquiera me guía qué error estoy haciendo aquí ?cómo hacer que httpPost llame con el cuerpo json codificado?
simple resto de clientes que formuló la siguiente:
URL: http://jon2012.com/api/register Método: Enviar encabezados: No hay encabezados, ya que no se requieren datos : { "e-mail": "[email protected]", "nombre apellido": "Nombre"}
Código Android:
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); //Timeout Limit
HttpResponse response;
JSONObject json = new JSONObject();
try{
HttpPost post = new HttpPost(url);
json.put("email", email);
json.put("first_name", name);
StringEntity se = new StringEntity("JSON: " + json.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setEntity(se);
response = client.execute(post);
/*Checking response */
/*if(response!=null){
InputStream in = response.getEntity().getContent(); //Get the data in the entity
*/
int statusCode = response.getStatusLine().getStatusCode();
}
catch(Exception e){
e.printStackTrace();
// createDialog("Error", "Cannot Estabilish Connection");
}
cualquier ayuda appriciated
Es su patrón de datos JSON es igual que el servicio requerido? –