php - Can json data be sent to web service using GET request? -


i want send json data contains login information webservice using get request. doing right following,

public jsonobject getjsondata(string url) {          stringbuilder stringbuilder = new stringbuilder();         jsonobject jsonobject = new jsonobject();         jsonobject jsonsend = new jsonobject();         jsonsend.addproperty("email","email@gmail.com");         jsonsend.addproperty("password","*********");         httpurlconnection conn = null;         try {             url url1 = new url(url.tostring());              conn = (httpurlconnection) url1                     .openconnection();             conn.setrequestmethod("get");             conn.setdooutput(true);             conn.setdoinput (true);             conn.setrequestproperty("content-type", "application/json");             conn.setrequestproperty("accept", "application/json");             conn.connect();             outputstream out = null;             out = new bufferedoutputstream(conn.getoutputstream());             bufferedwriter writer = new bufferedwriter(new outputstreamwriter(out, "utf-8"));             writer.write(jsonsend.tostring());             log.e("jsondata", jsonsend.tostring());             writer.close();             out.close();             conn.getresponsecode();             inputstreamreader in = new inputstreamreader(                     conn.getinputstream());              int b;             while ((b = in.read()) != -1) {                 stringbuilder.append((char) b);             }             try {                 log.e("stringbuilder",stringbuilder.tostring());                 jsonobject = new jsonobject(stringbuilder.tostring());             } catch (jsonexception je) {                 toast.maketext(this, "error while creating json", toast.length_short).show();             }         } catch (exception e) {             e.printstacktrace(); //            toast.maketext(getapplicationcontext(), e.getmessage(), toast.length_short).show();             try { //                toast.maketext(getapplicationcontext()," code", toast.length_short).show();             } catch (exception e1) {                 // todo auto-generated catch block                 e1.printstacktrace();             }         }         {             conn.disconnect();         }         return jsonobject;     } 

even though specifying request method get, it's trying insert data in webservice. webservice has php code accept json data , return json data if user credentials valid , accepts request. please let me know how can solve this. thanks..

you cant define content type in get() request type. cant send json in request. able sent headers in request in header cant send json file.


Comments