Solved

Rest Service Query with limit

Posted on 2014-11-19
3
239 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Data center, now-a-days, is referred as the home of all the advanced technologies. In-fact, most of the businesses are now establishing their entire organizational structure around the IT capabilities.
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now