0

I am trying to execute the following call ("api/test/sin=2129VAH99,8974922&sip=108124AG3") from the code below, but I cannot seem to get the call to work, as it keeps responding with 'no data' error.

 public HttpResponseMessage Get([FromUri] Query query)
    {
        var data = db.database_Items.AsQueryable();

        if (!String.IsNullOrEmpty(query.sip))
        {
            var ids = query.sip.Split(',').ToList();

            data = data.Where(c => ids.Any(i => (c.SIP != null && c.SIP.Contains(i))));
        }

        if (!String.IsNullOrEmpty(query.sin))
        {
            var ids = query.sin.Split(',').ToList();

            data = data.Where(c => ids.Any(i => (c.SINs != null && c.SINs.Contains(i))));
        }


        if (!data.Any())
        {

            return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
        }

        return Request.CreateResponse(HttpStatusCode.OK, data);
    }

Any help/guidance would be very much appreciated. Many thanks.

2
  • Assuming you are searching for the full SIP / SIN string, possibly you mean data = data.Where(c => c.SIP != null && ids.Contains(c.SIP)); ?
    – StuartLC
    Jan 13, 2014 at 15:08
  • Thank you for your response. I tried using that statement you have suggested above and many more like so and unfortunately, i an still experiencing 'no data error' on the client-end of the api call. Jan 13, 2014 at 15:13

1 Answer 1

0

Try to change your Url to :

api/test?sin=2129VAH99,8974922&sip=108124AG3

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.