Click here to Skip to main content
14,268,822 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have two solutions running on my desktop: One is a web solution using angularjs and calling the other solution which is a web API based on MVC and both are written in Everything is working perfectly except one thing: when I tried to send a bi-dimensional I got below error:

The request is invalid. The parameters dictionary contains an invalid entry for parameter 'myBiDimenArray' for method 'System.Web.Http.IHttpActionResult Calculate(System.String[,], Int32)' in 'CustomAPI.TestController'. The dictionary contains a value of type 'System.String[]', but the parameter requires a value of type 'System.String[,]'."

Below is my code in angular js:

var myBiDimenArray = [
            [1, 6],
            [5, 2],
            [9, 10]

console.log(myBiDimenArray); // it logs the array correctly

return $http({
            method: "GET",
            url: urlBase + "Calculate",   
            params: {
                myBiDimenArray: myBiDimenArray,
                intSize: 1,
            headers: {
                'Content-Type': 'application/json',
                'X-ApiKey': 'test' ,
                'Authorization': 'Basic 123456'

Below is my code in Web APi:

    Public Function Calculate(<FromUri> ByVal myBiDimenArray(,) As String, <FromUri> ByVal intSize As Integer) As IHttpActionResult
 End Function

Any suggestions?

I am new to this, I have searched for how to create Bi-Dimen Array in and in JavaScript so I implemented the above in my solutions but error 400 is thrown and method is even not accessed.


Please note that this is my route in webAPi config file:

config.Routes.MapHttpRoute( _
 name:="Test_Calculate", _
 routeTemplate:="api/{controller}/{action}/{myBiDimenArray}/{intSize}", _
 defaults:=New With {.controller = "Test", .action = "Calculate"} _

Could it be a configuration problem?

What I have tried:

I have changed the web APi method to this:
    Public Function Calculate(<FromUri> ByVal myBiDimenArray()() As String, <FromUri> ByVal intSize As Integer) As IHttpActionResult
 End Function

The method could be accessed, myBiDimenArray length was 3 (which is correct), but each array inside was acting like a String, example: "[1,6]" : 1 parameter instead of being 2 params inside an array;
Updated 27-Nov-17 19:03pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100