Solved

Rest Service Query with limit

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

707 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

18 Experts available now in Live!

Get 1:1 Help Now