You cannot post data in non-JSON format when using Jsonobjectrequest, so you can use Stringrequest to get the corresponding data and then convert to JSON-formatted data.
//the context here needs to be discussedprivate static Requestqueue Mrequestqueue =Volley.newrequestqueue (Global.getcontext ());p ublic interface iresponse{void Subscribedata (Object data);}/**post way to get data from the network*/Public static void Postdatafromnet (Final iresponse iresponse, String URL, final HashMap<String,String>map) {Stringrequest Request=New Stringrequest (Request.Method.POST, URL, new Response.listener<String>() {@Override public void Onresponse (String response) {try { Iresponse.subscribedata (new Jsonobject (response)); //returning data to} catch (Jsonexception e) {e.printstacktrace (); }}, new Response.errorlistener () {@Override public void Onerrorresponse (Volleyerror volleyerror) {LOG.E ("#StringRequest: error#", Volleyerror.getmessage ()); }}) {@Override public Map<string, string>Getheaders () throws Authfailureerror {Map<String,String> Header = new hashmap<>();Header.put ("token", "9foyt495e6bcflokye36f8c618533c3e"); return header; } @Override protected Map<string, string>Getparams () throws Authfailureerror {return map; } }; Request.settag (""+URL); Mrequestqueue.add (Request); }
Volley post non-JSON format data and get JSON data