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.
2
  • 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] Commented Feb 14, 2017 at 2:35
  • I solved it! I created a compose object like this example and a merge my array like this other answered question Commented Feb 14, 2017 at 23:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.