Solved

Rest Service Query with limit

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There is no doubt that cloud is gaining importance. Many of you must have read about this technology and its growing importance. More and more organisations are embracing this technology not forgetting start-ups. The process begins by dipping …
When speed and performance are vital to revenue, companies must have complete confidence in their cloud environment.
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

687 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