locked
Odata get 406 not Acceptable error RRS feed

  • Question

  • User1706495507 posted
    We have a problem with Odata get?every time add $select to 
    URL  http://url/Clients?$select=Firstname we have 406 error.
    when I add $select=Firstname to URL it goes to else and returns 406 not Ac

    public IHttpActionResult Get(ODataQueryOptions<Client> options)
    {
        IQueryable queryNew = ODataDynamicPropertyUtilities.ConvertQueryToJsonData<Client>(options.ApplyTo(db.Clients.Include(p => p.ClientTags).ThenInclude(q => q.Tag)));
     
        if (queryNew.ElementType == typeof(Client))
        {
            var results = queryNew.Cast<Client>().ToList();
            return Ok(results);
        }
        //this part cause 406 error 
        else //if (queryNew.ElementType.Name == "SelectSome`1")
        {
            var results = new List<object>();
            foreach (var item in queryNew)
            {
                results.Add(item);
            }
     
            return Ok(results);
        }
     
    }
    


    Wednesday, August 16, 2017 7:58 PM

All replies