0

I have this function in my Web api 2:

    // POST: Análise CR    
        [HttpPost]
        [Route("api/insertanaliseCR/{NumSerie_app}/{amostrador}/{Documento}")]
        [ResponseType(typeof(object))]
        public async Task<IHttpActionResult> insertanaliseCR(string NumSerie_app, string amostrador, string Documento, TBAnaliseCR analiseCR, TBAnaliseFQ analiseFQ)
        { 
             [...] //some code
         }

Its everything ok in Visual Studio!

So I want to call it in my angularjs service:

//POST analiseCR 
EmpApi.insertanaliseCR = function (analiseCR, analiseFQ, NumSerie_app, amostrador, Documento) {

    return $http.post(urlBase + '/insertanaliseCR/' + NumSerie_app +
                                                '/' + amostrador +
                                                '/' + Documento,
                                                analiseCR,
                                                analiseFQ



                                            );
}

EmpApi it my factory, i already declared it, and it's working.

But the connection between service angular and my web service is not working. Is there anything wrong in the way that I'm passing the params in angularjs?

Erros did I got:

Object { data: null, status: -1, headers: headersGetter/<(), config: Object, statusText: "" }

Object { Message: "An error has occurred.", ExceptionMessage: "Can't bind multiple parameters ('an…", ExceptionType: "System.InvalidOperationException", StackTrace: "   at System.Web.Http.Controllers.H…" }

Can't bind multiple parameters ('analiseCR' and 'analiseFQ') to the request's content.
kfm
  • 143
  • 3
  • 17
  • Your going to need to create an object and assign the last two paramaters to it. Since you are using the POST method, i'm guessing you want those last two params to be sent in the requests body, so you'll have to specify that in your webapi code by using [FromBody] – Mike Lunn Feb 14 '17 at 02:35
  • I solved it! I created a compose object [like this example](http://stackoverflow.com/questions/24874490/pass-multiple-complex-objects-to-a-post-put-web-api-method#) and a merge my array [like this other answered question](http://stackoverflow.com/questions/42235978/angularjs-join-two-objects) – kfm Feb 14 '17 at 23:28

0 Answers0