Sending JSONObject data

0

I have a problem with my Android Studio code. My application must send some information that is collected but I do not know how to structure it since the body of the email is long someone could tell me, I have tried to send it with several JSONObjects but I have not been successful I hope you can help me.

 HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
                urlConnection.setDoOutput(true);
                urlConnection.setDoInput(true);
                urlConnection.setRequestMethod("POST");
                urlConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
                urlConnection.setConnectTimeout(10000);
                urlConnection.setReadTimeout(10000);
                Authenticator.setDefault(new Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication("WSUser", "Tums4.WS".toCharArray());
                    }
                });

I leave the structure of the body:

{
  "Equipo": {
    "EquipoMotriz": "test",
    "Viajes": {
      "NoViaje": "test",
      "Repartos": {
        "Reparto": {
          "Pedido": "test",
          "CartaPorte": "test",
          "CargaFecIniR": "test",
          "CargaHorIniR": "test",
          "CargaFecFinR": "test",
          "CargaHorFinR": "test",
          "DescFecIniR": "test",
          "DescHorIniR": "test",
          "DescFecFinR": "test",
          "DescHorFinR": "test",
          "LlegaCteFecR": "test",
          "LlegaCteHorR": "test",
          "SalidCteFecR": "test",
          "SalidCteHorR": "test",
          "LlegaCteDesFecR": "test",
          "LlegaCteDesHorR": "test",
          "SalidCteDesFecR": "test",
          "SalidCteDesHorR": "test",
          "Paradas": {
            "Parada": {
              "NUM_VIAJE": "test",
              "PEDIDO": "test",
              "ENTREGA": "test",
              "CVE_PAR": "test",
              "CLA_PAR": "test",
              "TIP_PAR": "test",
              "LATITUD": "test",
              "LONGITUD": "test",
              "FECHA_C": "test",
              "HORA_C": "test"
            }
          }
        }
      }
    }
  }
}
    
asked by Giovanni Antonio Carrillo Muji 21.12.2018 в 00:01
source

0 answers