Solved

Rest Service Query with limit

Posted on 2014-11-19
3
246 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
  • 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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Learn how the use of a bunch of disparate tools requiring a lot of manual attention led to a series of unfortunate backup events for one company.
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, fr…
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…

773 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