user5653405 user5653405 - 4 months ago 8
Android Question

how i post json string when i post then show me message input data is require in logcat

API=

public static String getaddProject="http://10.10.10.64:10003/API/Project/Add";

for(int i=0; i<iArr.size(); i++){

if(i==0){

st = "{\"userId\":" + iArr.get(i) + "}";
str += st;
}else if(i>0 && i<iArr.size()-1){
st = ",{\"userId\":" + iArr.get(i) + "}";
str+=st;
}else if(i==iArr.size()){
st = ",{\"userId\":" + iArr.get(i) + "}]}";
str+=st;
}
}
String myPost = "{\"project\":{\"Name\":"+ "\""+ title + "\""
+ ",\"Description\":" + "\""+ desc + "\""
+ ",\"createdBy\":" + usrid + ""
+ ",\"startDate\":" + "\""+ startdate + "\""
+ ",\"dueDate\":" + "\""+ duedate + "\""
+ ",\"projectLeadId\":" + leadPosition + ""
+ ",\"QAId\":" + QAssurencePosition + ""
+ ",\"TotalHour\":" +"\""+ edtHour + "\""+ "},\"members\":[";
myPost += str;
myPost +="]}";
RequestPackage myPackage = new RequestPackage();
myPackage.setUri(getaddProject);
myPackage.setMethod("POST");
myPackage.setParam("My Post",myPost+"");
new MyTask().execute(myPackage);
Toast.makeText(CreateProject.this,"Testing String: " + myPost,Toast.LENGTH_LONG ).show();

Log.d("My Post :",myPost);
}

Answer

In your MyTask class you have doInBackground method witch have to return your string answer and pass it to onPostExecute. Then in you will have :

 protected void onPostExecute(String answer) {
     Toast.makeText(CreateProject.this,"Testing String: " + answer,Toast.LENGTH_LONG ).show();
 }