locked
APIExplorer and complex type binding RRS feed

  • Question

  • User-707586530 posted

    APIExplorer class does not bind [FromUri] complex parameter to URI Querys string.

    ex. if i am passing array of string as a parameter in querystring and in my action method i have parameter is of type actionmethod([FromUri] string[] Param1) then it does not map query tring to Param1 object

    Monday, October 26, 2015 4:04 PM

All replies

  • User1066278571 posted

    Here are some examples which shows you how to do it

    http://damienbod.com/2014/08/22/web-api-2-exploring-parameter-binding/

    Greetings Damien

    Monday, October 26, 2015 4:50 PM
  • User-707586530 posted

    Hi Damien,

    Thanks for your reply. i have alreay gone though it but my problem is APIExplorer class does not bind the complex parameer which is comming from URI.

    i thought the probleme lies in "IsSimpleUnderlyingType(parameterType)" which is used in second line of below code of APIExplorer class

    Type parameterType = parameterDescriptor.ParameterDescriptor.ParameterType;
    if (parameterDescriptor.Source == ApiParameterSource.FromUri && TypeHelper.IsSimpleUnderlyingType(parameterType))
    }{ parameterValuesForRoute.Add(parameterDescriptor.Name, "{" + parameterDescriptor.Name + "}");

    Tuesday, October 27, 2015 3:34 AM
  • User-219423983 posted

    Hi Kandarpdave,

    Kandarpdave

    i thought the probleme lies in "IsSimpleUnderlyingType(parameterType)" which is used in second line of below code of APIExplorer class

    Type parameterType = parameterDescriptor.ParameterDescriptor.ParameterType;
    if (parameterDescriptor.Source == ApiParameterSource.FromUri && TypeHelper.IsSimpleUnderlyingType(parameterType))
    }{ parameterValuesForRoute.Add(parameterDescriptor.Name, "{" + parameterDescriptor.Name + "}");

    It's a know issue and you could have a look at the following similar thread. Maybe this issue would be resolved in next version. If you want to bind the complex type from query string, the link above is a good method.

    http://forums.asp.net/t/1835575.aspx?ApiExplorer+and+parameters+of+complex+type

    I hope it’s useful to you.

    Best Regard,

    Weibo Zhang

    Tuesday, October 27, 2015 7:51 AM