Passing 3 parameters from angularjs $resource to C# Web API Controller Post method, one of the parameters returns null -


i have been trying pass 3 parameters post method angularjs c# web api controller. information being passed angularjs service correctly. have tried many combinations on client , server side post method receive multiple parameters closest have come 2/3.

here code.

server side controller:

// post api/values

    [httppost("{id}")]      public iactionresult post(int id, string userid, [frombody]post post)     {         if(post.id == 0)         {              _repo.addpost(id, userid, post);         }         else         {             _repo.updatepost(post);         }         return ok(post);     } 

client side service: namespace myapp.services {

export class postsservice {     private postsresource;      constructor(private $resource: ng.resource.iresourceservice) {         this.postsresource = this.$resource("/api/posts/:id");     }      getpost(id) {         return this.postsresource.get({ id: id });     }       savepost(id, userid, posttosave) {         return this.postsresource.save({ id: id }, { userid: userid }, posttosave).$promise;     }      deletepost(id) {         return this.postsresource.delete({ id: id }).$promise;     } }  angular.module("myapp").service("postsservice", postsservice); 

}

any tips or suggestions? appreciated!


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -