What's wrong with my put? It was to update objects in my database, but it does not work correctly, it does not return any errors, it just does not update.
public String doInBackground(String... arg0) {
String result = "";
try {
URL url = new URL("http://192.168.1.207/api/v2/bookdemo/_table/cad_users");
JSONObject jsonObject = new JSONObject();
String json = "";
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Content-type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
conn.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.XXXXXXXXXX.jfGbU3yjIPPfAQWTyYVQJCfEapYFnHPCYkL4T-arD4M");
conn.setRequestProperty("Authorization", "Basic XXXXXXXXXXXX");
conn.setRequestMethod("PUT");
conn.setReadTimeout(15000 /* milliseconds */);
conn.setConnectTimeout(15000 /* milliseconds */);
conn.setDoInput(true);
conn.setDoOutput(true);
json = jsonObject.toString();
jsonObject.put("id_user", id);
jsonObject.put("tx_name", nome);
jsonObject.put("tx_nickname", nickname );
jsonObject.put("nu_cellphone", numcel );
jsonObject.put("password", password );
jsonObject.put("tx_email", email );
Log.e("resource", jsonObject.toString());
JSONObject resource = new JSONObject();
JSONArray array = new JSONArray();
array.put(json);
resource.put("resource", array);
System.out.println(resource.toString());
conn.connect();
OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
writer.write(resource.toString());
writer.flush();
writer.close();
os.close();
int responseCode = conn.getResponseCode();
System.out.println("Chegou até aqui");
if (responseCode == HttpsURLConnection.HTTP_OK) {
System.out.println("Funcionou");
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuffer sb = new StringBuffer("");
String line = "";
while ((line = in.readLine()) != null) {
sb.append(line);
break;
}
Return systems ... 07-25 14: 16: 32,248 21317-22373 / com.example.thiago.myapplication E / resource: {"id_user": "2", "tx_name": "Test", "tx_nickname": "Test", "nu_cellphone ":" (11) 99838-9998 "," password ":" 12345 "," tx_email ":" [email protected] "} 07-25 14: 16: 32.258 21317-22373 / com.example.thiago.myapplication I / System.out: {"resource": ["{}"]}