Using Android Volley with ASP .NET Web API -


i trying retrieve resource asp .net restful service android client. have messagescontroller has method getmessages:

[authorize] public iqueryable<message> getmessages() {     return db.messages; } 

to access have sent request /token , have obtained key use client application access resource. trouble have client receiving 302 http error when trying access resource.

this method in android client:

public void setallsendersandallmessages() {     string url = "messages/getmessages";     showpdialog();     string url = baseurl + url;       jsonarrayrequest req = new jsonarrayrequest(url,             new response.listener<jsonarray>() {                  @override                 public void onresponse(jsonarray response) {                     log.d(tag, response.tostring());                      try {                          allsenders = new string[response.length()];                         allmessages = new string[response.length()];                         (int = 0; < response.length(); i++) {                              jsonobject message = (jsonobject) response.get(i);                              allsenders[i] = message.getstring("sender");                             allmessages[i] = message.getstring("messagecontent");                         }                         setinitialviews();                      } catch (jsonexception e) {                         e.printstacktrace();                         toast.maketext(context, "error: " + e.getmessage(), toast.length_long).show();                     }                      hidepdialog();                 }             }, new response.errorlistener() {         @override         public void onerrorresponse(volleyerror error) {             volleylog.d(tag, "error: " + error.getmessage());             toast.maketext(context,error.getmessage(), toast.length_short).show();             hidepdialog();         }     }){         @override         public map<string, string> getheaders() throws authfailureerror {             map<string, string>  headers = new hashmap<>();             headers.put("authorization", "bearer "+ token);             return headers;         }     };      mrequestqueue.add(req);  } 

i overriding getheaders() method send authorization token service. key , header works when using 'postman' fails in android client unknown reason. if can offer advice appreciated!

http 302 url error, url must : http://server/wepapi/api/orders

server : iis server name , or server ip address


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -