android - Retrofit 500 Internal server error getting data -


i'm starting out retrofit, i'm trying data server via @post request keep returning 500 internal server error.

my aim send user name through request , server should return json string containing list of data given user.

i'm sure simple i'm fresh using retrofit, code below:

my servicegenerator(uses authentication):

private static final string url = "http://ip address/projectzws/projectzwebservice.asmx";  private static restadapter.builder builder = new restadapter.builder()         .setendpoint(url)         .setclient(new okclient(new okhttpclient()));  public static <s> s createservice(class<s> serviceclass, string username, string password) {     if (username != null && password != null) {         // concatenate username , password colon authentication         string credentials = username + ":" + password;         // create base64 encodet string         final string basic =                 "basic " + base64.encodetostring(credentials.getbytes(), base64.no_wrap);          builder.setrequestinterceptor(new requestinterceptor() {             @override             public void intercept(requestfacade request) {                 request.addheader("authorization", basic);                 request.addheader("accept", "application/x-www-form-urlencoded");              }         });     }      restadapter adapter = builder.build();     return adapter.create(serviceclass); 

my service class:

    @formurlencoded     @post("/getdata")     public void getdata(@field string user, callback<list<data>> callback); 

and main activity code:

 instituteservice service = restservice.createservice(instituteservice.class, "user", "pass");     service.getdata("auser","",new callback <list<data>>() {         @override         public void success(list<data> data, response response) {             toast.maketext(ctx, "success!!!!", toast.length_short).show();         }         @override         public void failure(retrofiterror error) {             toast.maketext(ctx, error.getmessage().tostring(), toast.length_long).show();         }     }); 

server log:

2015-10-31 10:47:02 192.168.1.14 post /projectzws/projectzwebservice.asmx/getreviews - 80 jeff 176.61.63.95 okhttp/2.5.0 - 500 0 0 1328

request information: request url: http://32.17.47.56/projectzws/projectzwebservice.asmx/ request path: /projectzws/projectzwebservice.asmx/ user host address: 176.61.65.876 user: pc\the pc authenticated: true authentication type: basic thread account name: iis apppool\asp.net v4.0 classic

thread information: thread id: 10 thread account name: iis apppool\asp.net v4.0 classic impersonating: false stack trace: @ system.web.script.services.resthandler.createhandler(httpcontext context) @ system.web.script.services.scripthandlerfactory.gethandler(httpcontext context, string requesttype, string url, string pathtranslated) @ system.web.httpapplication.maphttphandler(httpcontext context, string requesttype, virtualpath path, string pathtranslated, boolean useappconfig) @ system.web.httpapplication.maphandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() @ system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously)

process information: process id: 3288 process name: w3wp.exe account name: iis apppool\asp.net v4.0 classic

exception information: exception type: invalidoperationexception exception message: invalid web service call, expected path info of /js/. @ system.web.script.services.resthandler.createhandler(httpcontext context) @ system.web.script.services.scripthandlerfactory.gethandler(httpcontext context, string requesttype, string url, string pathtranslated) @ system.web.httpapplication.maphttphandler(httpcontext context, string requesttype, virtualpath path, string pathtranslated, boolean useappconfig) @ system.web.httpapplication.maphandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() @ system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously)

the server asmx, , when server sent getdata method returns json string requested data (i have server guy working backend , seems happy server responding fine getdata(auser) command?). server seeing seems rubbish?

any appreciated.

problem resolved, issue in service class, added @field annotation & added @field annotation , key, value pair in method call , works treat. functional code edited in initial post above, below final fix code:

@formurlencoded @post("/getdata") public void getdata(@field string user, callback<list<data>> callback); 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -