Base solution for your next web application

Activities of "vallygao"

Hi, Recently, I got a problem that how does ABP provide interface to Android or others. RE, I have a interface like ".../api/services/Assistant/customer/getAllCustomer",and this method with parameter state. How to call the web API directly? How to pass parameters? How web API receive parameters?

Please help me!

Thanks for your reply. :D I have added a web api controller,but it still has something confusing me :(

when use the method get ,it's all ok. use the method post without parameter,it' s still noting wrong. but when use the method post with parameters,it returns error"an internal error occured during your request"

here's my code: controller:

public class ContactController : AbpApiController
    {
        Contact[] contacts = new Contact[] { 
            new Contact(){ ID=1, Age=23, Birthday=Convert.ToDateTime("1977-05-30"), Name="Jone", Sex="M"},
            new Contact(){ ID=2, Age=55, Birthday=Convert.ToDateTime("1937-05-30"), Name="Brown", Sex="M"},
            new Contact(){ ID=3, Age=12, Birthday=Convert.ToDateTime("1987-05-30"), Name="Lily", Sex="F"},
            new Contact(){ ID=4, Age=18, Birthday=Convert.ToDateTime("1997-05-30"), Name="Lucy", Sex="F"},
        };

        [HttpGet]
        public virtual IEnumerable<Contact> GetListAll()
        {
            return contacts;
        }

        [HttpPost]
        public virtual IEnumerable<Contact> QueryLists([FromBody]int state)
        {
            return contacts.Where(con=>con.ID==state);
        }
  }

the method get:

$('#send_ajax').click(function(){
                $.ajax({
                    url:'http://...../api/Contact/GetListAll',
                    type:'get',
                    data:{},
                    success:function(data){
                        //alert(data);
                    },
                    error:function(data){
                        //var myjson='';
                    }
                });
            });

the result:

[{"id":1,"name":"Jone","sex":"M","birthday":"1977-05-30T00:00:00","age":23},{"id":2,"name":"Brown","sex":"M","birthday":"1937-05-30T00:00:00","age":55},{"id":3,"name":"Lily","sex":"F","birthday":"1987-05-30T00:00:00","age":12},{"id":4,"name":"Lucy","sex":"F","birthday":"1997-05-30T00:00:00","age":18}]

the method post :

$('#send_ajax').click(function(){
                $.ajax({
                    url:'http://....../api/Contact/QueryLists',
                    type:'post',
                    data:{"state":1},
                    success:function(data){
                        //alert(data);
                    },
                    error:function(data){
                    }
                });
            });

the result:

{"success":false,"result":null,"error":{"code":0,"message":"An internal error occurred during your request!","details":null,"validationErrors":null},"unAuthorizedRequest":false}

Do you have some solutions ?waitting for your good news.

yes,i did. but i don't understand what causes.here's the log:

ERROR 2015-08-03 16:09:30,907 [73   ] lers.Filters.AbpExceptionFilterAttribute - System.Web.Http.HttpResponseException: Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.
   在 System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)
   在 System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)
   在 System.Web.Http.ModelBinding.FormatterParameterBinding.<ExecuteBindingAsyncCore>d__0.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 System.Web.Http.Controllers.HttpActionBinding.<ExecuteBindingAsyncCore>d__0.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
System.Web.Http.HttpResponseException: Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.
   在 System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)
   在 System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)
   在 System.Web.Http.ModelBinding.FormatterParameterBinding.<ExecuteBindingAsyncCore>d__0.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 System.Web.Http.Controllers.HttpActionBinding.<ExecuteBindingAsyncCore>d__0.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()

All modules in navigation should set the NavigationProvider.cs and app.js, Now ,we need to dynamically load the module, What should we do now? we need your help,Thanks :)

Showing 1 to 4 of 4 entries