?
Solved

Rest Service Query with limit

Posted on 2014-11-19
3
Medium Priority
?
266 Views
Last Modified: 2014-11-26
I am querying a rest service using a httpwebrequest which by default limits the returned data to 100 records.  I am using date parameters within the query and I also wish to increase the limit to 500 records.

 The current working query:

The true query string is constructed using a class object and is json  serialized.  The sample is used to show the request content!  

query  =?where={"_createdAt":{"$gte":{"$date":"2014-11-12T09:17:59.5894738Z"},"$lt":{"$date":"2014-11-20T09:17:59.5894738Z"}}}

 request = DirectCast(WebRequest.Create("https://api.mydata.com/rest/1/db/collections/jobs" & query), HttpWebRequest)

how would i add the limit parameter to the existing query.  I have tried simply appending the limit to the request which does not break the query but also it does not limit the results!  How do you construct both elements the date delimiter and the limit?
0
Comment
Question by:JoeBo747
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40455262
I don't understand the question, so I am not sure how I can help you.  What would the "limit parameter" be?
0
 
LVL 1

Author Comment

by:JoeBo747
ID: 40457068
Sorry Bob I thought it was clear I will try to explain.

The MungoDB database is in the cloud and has to be queried using Json.

The limit is a parameter that can be passed along with the URL https://api.mydata.com/rest/1/db/collections/jobs?limit=200
The query above would return a collection of 200 objects and works.  
The query to return a collection of objects within a date range https://api.mydata.com/rest/1/db/collections/jobs?where={"_createdAt":{"$gte":{"$date":"2014-11-12T09:17:59.5894738Z"},"$lt":{"$date":"2014-11-20T09:17:59.5894738Z"}}} this also works.

What I wish to achieve is a combination of both query's which would return a collection of 200 objects which falls within the date range.  I have attempted to append the  limit to the date query by simply adding it to the query as in https://api.mydata.com/rest/1/db/collections/jobs?where={"_createdAt":{"$gte":{"$date":"2014-11-12T09:17:59.5894738Z"},"$lt":{"$date":"2014-11-20T09:17:59.5894738Z"}}}?limit=200 this does not break the query but returns a collection of objects in the date range but with a limit of 100 the default collection size.  I hope this is a clearer explanation of my problem.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 40457423
If it is an additional query string argument, then I would think that the syntax would be like this:

https://api.mydata.com/rest/1/db/collections/jobs?where={"_createdAt":{"$gte":{"$date":"2014-11-12T09:17:59.5894738Z"},"$lt":{"$date":"2014-11-20T09:17:59.5894738Z"}}}&limit=200
0

Featured Post

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many CHPs use the buzzword ‘Cloud Hosting’ to sell the idea of reliability. Most consumers have the opinion that cloud hosting is easily scalable and can handle just about anything. Further, most CHPs are not transparent and hide the underlying arch…
Each year, investment in cloud platforms grows more than 20% (https://www.immun.io/hubfs/Immunio_2016/Content/Marketing/Cloud-Security-Report-2016.pdf?submissionGuid=a8d80a00-6fee-4b85-81db-a4e28f681762) as an increasing number of companies begin to…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Both in life and business – not all partnerships are created equal. Spend 30 short minutes with us to learn:   • Key questions to ask when considering a partnership to accelerate your business into the cloud • Pitfalls and mistakes other partners…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question