0

I want to load the details based on the user location. When I query for the results it is always returning empty array. What to do? This is my query:

https://api.parse.com/1/classes/TSLocation?where{"location":"{\"nearSphere\":{\"__type\":\"GeoPoint\",\"latitude\":34.944251,\"longitude\":-111.753343}}","limit":10}

I have also added the headers along with the HttpRequest. Can you please guide if anybody knows

sarvesh
  • 2,743
  • 1
  • 20
  • 30
Chaitu
  • 907
  • 2
  • 13
  • 27

2 Answers2

2

Finally I got it..actually my query was wrong.In the above query at location i am passing JsonString instead of JSONObject.

Formatted Query is: https://api.parse.com/1/classes/TSLocation?where={"location":{"$nearSphere":{"__type":"GeoPoint","longitude":-74.00594130000002,"latitude":40.7127837}}}&limit=10

Chaitu
  • 907
  • 2
  • 13
  • 27
0

It is $nearSphere not nearSphere, try this

https://api.parse.com/1/classes/TSLocation?where{"location":"{\"$nearSphere\":{\"__type\":\"GeoPoint\",\"latitude\":34.944251,\"longitude\":-111.753343}}"}&limit=10
sarvesh
  • 2,743
  • 1
  • 20
  • 30
  • Yeah.. I have changed it and query executed successfully.. but the above query is returning 100 rows from TSLocation table,my intent is to fetch 10 records at a time..Although I have included limit condition but it os not working..Can you please tell me – Chaitu Oct 30 '14 at 05:06
  • Limit is a separate query string parameter check the updated answer. – sarvesh Oct 30 '14 at 14:57
  • Thanks @sarvesh ..Limit is working..The above query is executing but results are not accurate I think where condition is not working Is that the above query Correct?(i.e.,where or where=). If I didnot mention =operator results will come (which are not satisifed the condition),If I mention the =operator results are returned with an empty array. Can you please tellme..I have been searching since 2 days.... – Chaitu Oct 31 '14 at 13:16
  • You statements are contradictory, you said the query worked and then it doesn't. Are you sure you didn't change something. You were getting 100 records and wanted 10 right? – sarvesh Nov 01 '14 at 19:49
  • Sorry If I were wrong..limit condition is working(i.e. It is returning the results based on the limit I gave).What I want to achieve is I need to fetch 10results based on the user location.If I execute the above condition with lat and long values It is returning the results, although I gave wrong co ordinates also it is returning the same results.This is my problem.Can you please tell me.How to achieve this. – Chaitu Nov 03 '14 at 04:40
  • Are you absolutely sure it is the same set of objects? It would hard debug without all the code and data. You should try the curl command (https://www.parse.com/docs/rest#geo) for this app and see if you get different result then it narrows it down to your app. Good luck. – sarvesh Nov 03 '14 at 15:55