Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Array of parameters in the WebAPI service

$
0
0
<div class="post-text" itemprop="text">

Experts,

Having issue while passing the array of parameters in the WEB API service

public class SampleController : ApiController
{
   public string Getdetails([FromUri] int[] id)
  {
    var inconditions = id.Distinct().ToArray();
    using (var dbConn = new OracleConnection("DATA SOURCE=h;PASSWORD=C;PERSIST SECURITY INFO=True;USER ID=T"))
    {
        dbConn.Open();
        var strQuery = "SELECT PRIO_CATEGORY_ID AS PRIO, LANG_ID AS LANG, REC_DATE AS REC, REC_USER AS RECUSER, DESCR, COL_DESCR AS COL, ROW_DESCR AS DROW, ABBR FROM STCD_PRIO_CATEGORY_DESCR WHERE REC_USER  IN (:p)";
        var queryResult = dbConn.Query<SamModel>(strQuery, new { p = inconditions });
        return JsonConvert.SerializeObject(queryResult);
    }
}

}

Now while calling the API as http://localhost:35432/api/Sample?id=1&id=83 it throws an error saying on var queryResult = dbConn.Query(strQuery);

{"ORA-00907: missing right parenthesis"}

enter image description here

checked all the paranthesis and everything looks good

</div>

Viewing all articles
Browse latest Browse all 4850


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>