Thanks for fast response Alexandr,
Let me please clarify and switch to real names of my data tables. Hope this will help in your investigation.
I have Cities, Companies and Rooms data tables with relations:
- one to one from Companies to Cities,
- one to one from Rooms to Companies.
I have Geolocation with “rooms” category and for each geo point established relation to one row from Rooms table.
I’m trying to get all rooms sorted by a distance for a particular company.
- Still can’t figure it out. My relation is called ‘company’ and when I’m using REST console in Data Management and check to load company relation it automatically adds ‘loadRelations=company’ to the request URL. Query executes correctly. When I try to do the same for geo query (adding ‘loadRelations=company’) I can’t see this data in the request result.
Adding curl request so you can see exactly what I’m talking about.
So this query works as expected - related companies are included.
curl -H application-id:"CCD7530E-CD7B-3B6E-FF2E-B153FE232B00" -H secret-key:"<secret_REST_API_key>" -H Content-Type:"application/json" -H application-type:REST -X GET -v "[url=https://api.backendless.com/v1/data/Rooms?loadRelations=company]https://api.backendless.com/v1/data/Rooms?loadRelations=company"[/url];
Lets switch to Geolocation. Response from this request doesn’t have companies included (I have also tried with loadRelations=rooms.company but the result is the same):
curl -H application-id:"CCD7530E-CD7B-3B6E-FF2E-B153FE232B00" -H secret-key:"<secret_REST_API_key>" -H Content-Type:"application/json" -H application-type:REST -X GET -v "[url=http://api.backendless.com/v1/geo/points?lat=52.12&lon=16.05&r=1000&units=KILOMETERS&categories=rooms&includemetadata=true&loadRelations=company]http://api.backendless.com/v1/geo/points?lat=52.12&lon=16.05&r=1000&units=KILOMETERS&categories=rooms&includemetadata=true&loadRelations=company"[/url];
- As for the second question let me also include some curl request.
This works fine:
curl -H application-id:"CCD7530E-CD7B-3B6E-FF2E-B153FE232B00" -H secret-key:"<secret_REST_API_key>" -H Content-Type:"application/json" -H application-type:REST -X GET -v "[url=http://api.backendless.com/v1/geo/points?lat=52.12&lon=16.05&r=1000&units=KILOMETERS&categories=rooms&includemetadata=true&where=rooms.objectId%3D%271083BD06-2A41-12E1-FFF0-463568C2AC00%27]http://api.backendless.com/v1/geo/points?lat=52.12&lon=16.05&r=1000&units=KILOMETERS&categories=rooms&includemetadata=true&where=rooms.objectId%3D%271083BD06-2A41-12E1-FFF0-463568C2AC00%27"[/url];
This returns 500 Internal Server Error (no difference if autoload company relation is checked in Data Management console or not)
curl -H application-id:"CCD7530E-CD7B-3B6E-FF2E-B153FE232B00" -H secret-key:"<secret_REST_API_key>" -H Content-Type:"application/json" -H application-type:REST -X GET -v "[url=http://api.backendless.com/v1/geo/points?lat=52.12&lon=16.05&r=1000&units=KILOMETERS&categories=rooms&includemetadata=true&where=rooms.company.objectId%3D%27A5611FEE-7D11-5710-FF67-2B7E4549DB00%27]http://api.backendless.com/v1/geo/points?lat=52.12&lon=16.05&r=1000&units=KILOMETERS&categories=rooms&includemetadata=true&where=rooms.company.objectId%3D%27A5611FEE-7D11-5710-FF67-2B7E4549DB00%27"[/url];
Similar request to above but directly for Rooms table works as expected:
curl -H application-id:"CCD7530E-CD7B-3B6E-FF2E-B153FE232B00" -H secret-key:"<secret_REST_API_key>" -H Content-Type:"application/json" -H application-type:REST -X GET -v "[url=https://api.backendless.com/v1/data/Rooms?where=company.objectId%3D%27A5611FEE-7D11-5710-FF67-2B7E4549DB00%27]https://api.backendless.com/v1/data/Rooms?where=company.objectId%3D%27A5611FEE-7D11-5710-FF67-2B7E4549DB00%27"[/url];
Hope this helps.
Best,
Matt