java - Getting HTTP 406 in Android Webservice Call -


i'm getting 406 when invoke rest web service via android application.can 1 suggest me error in code , why getting error ??

rest web service

@requestmapping(value="/mainreservationchartpost", method = requestmethod.post)     public @responsebody modelmap getmrchartdatapost(@modelattribute ("reservationsummaryrqdto") reservationsummaryrqdto search){          reservationsummarydto returndatadto = new reservationsummarydto();          mainreservationchartwsimpl wsimpl = mrwsutil.getinstance().getws_serviceport();          search.sethotelcode("bbh");         search.setreportdate(toxmldategmt(new date()));          returndatadto = wsimpl.getreservationsummary(search);          modelmap model = new modelmap();         model.put("reservations", returndatadto);          return model;      } 

android code

public static string post(string url, arraylist<namevaluepair> parameter)             throws exception {         bufferedreader in = null;         try {              defaulthttpclient httpclient = new defaulthttpclient();              httppost httpost = new httppost(url);             httpost.setheader("accept", "application*/*");             httpost.setheader("content-type",                     "application/x-www-form-urlencoded");             httpost.setentity(new urlencodedformentity(parameter, "utf-8"));             httpresponse response = httpclient.execute(httpost);              in = new bufferedreader(new inputstreamreader(response.getentity()                     .getcontent()));             stringbuffer sb = new stringbuffer("");             string line = "";             string nl = system.getproperty("line.separator");             while ((line = in.readline()) != null) {                 sb.append(line + nl);             }             in.close();             string result = sb.tostring();             return result;          } {             if (in != null) {                 try {                     in.close();                 } catch (exception e) {                     e.printstacktrace();                 }             }         }     }    @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);           arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>();         namevaluepairs.add(new basicnamevaluepair("hotelcode","bbh"));         //namevaluepairs.add(new basicnamevaluepair("reportdate","10-may-2013"));        //string response=hcc.executehttppost("http://10.2.241.137/ua_dat/rnd/senddata.php", namevaluepairs);          try {              string response=httpcustomclient.post("http://10.2.241.33/mrchartservice/mainreservationchart.html", namevaluepairs);            } catch (exception e) {             log.d("error", e.getmessage().tostring());          }         } 

any 1 can suggest how resolve ..? error in code because i'm getting 406 error ...

406 means type of data being requested in accept header of request , type returned server don't match. either change accepted type or change return mime type.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -