Help with Parse using the Query Constraints, LUA, JSON, network.request, Parse.com

Parse.com. Would somebody be prepared to show to use the Query Constraints? my GET function works without constraints…

eg a Corona version of the example on the Parse REST API docs would be great!

curl -X GET \
-H "X-Parse-Application-Id: MyID
-H "X-Parse-REST-API-Key: MyKey
-G \
–data-urlencode ‘where={“playerName”:“Sean Plott”,“cheatMode”:false}’ \
https://api.parse.com/1/classes/GameScore

I’ve tried many, many, many, many combinations including adding the data in params or in the URL, and with or without the urlencoding
Here’s an example of one combination, note my data is a simple AccessKey checking accessKey, myAppName against objects in the classes LoginVerif

local function verifyAccessKey(accessKey,myAppname)

headers[“Content-Type”] = “application/json”
local query = urlencode(value.encode ({“where” = {[“AccessKey”]= accessKey} }) )
params.body = nil
request = “loginverif” --my code in the listener
network.request( baseUrl … class.LoginVerif… query, “GET”, networkListener, params)

end
Parse.verifyAccessKey = verifyAccessKey

Also nor I’m not using the example USER login, I’m verifying access to an App via an AccessKey for a business service App.
Any help VERY much appreciated…

[import]uid: 137150 topic_id: 36453 reply_id: 336453[/import]

Haven’t actually tried this feature out yet, but have you tried:

[code]
local json = require (“json”)
local url = require(“socket.url”)

local dataTable = {}
dataTable[“AccessKey”] = accessKey

params.headers[“Content-Type”] = “application/json”
params.body = nil

local baseString = baseUrl … className … “/?where” … url.escape(json.encode(dataTable))

network.request( baseString, “GET”, networkListener, params)
[/code] [import]uid: 94868 topic_id: 36453 reply_id: 144723[/import]

Screaming Leaf is right.

This form works (pretty much the same thing):

 -- Use your usual headers plus the following:  
 headers["Content-Type"] = "application/x-www-form-urlencoded"  
  
 params.body = nil  
 query="?where="..urlencode(value.encode(obj))  
 network.request( "https://api.parse.com/1/classes/messages"..query, "GET", networkListener, params)  

Replace messages with the Parse class you use.
And obj refers to an object you created that corresponds with how your Parse class is defined. In my case, we had a class called message with fields such as “to” and I would create an object as such:

 local obj={}  
 obj.to=name  

So our query looked for messages “to” a user.

Full disclosure: AppRever does not use Parse.com but I have used this in other test code.

[import]uid: 233042 topic_id: 36453 reply_id: 144729[/import]

That works! For future reference the the first example needs a “=” after the where, so its “?where=”

Thanks again much appreciated

[import]uid: 137150 topic_id: 36453 reply_id: 144770[/import]

Thanks! That will help me out later when I get to this component of Parse. [import]uid: 94868 topic_id: 36453 reply_id: 144791[/import]

Haven’t actually tried this feature out yet, but have you tried:

[code]
local json = require (“json”)
local url = require(“socket.url”)

local dataTable = {}
dataTable[“AccessKey”] = accessKey

params.headers[“Content-Type”] = “application/json”
params.body = nil

local baseString = baseUrl … className … “/?where” … url.escape(json.encode(dataTable))

network.request( baseString, “GET”, networkListener, params)
[/code] [import]uid: 94868 topic_id: 36453 reply_id: 144723[/import]

Screaming Leaf is right.

This form works (pretty much the same thing):

 -- Use your usual headers plus the following:  
 headers["Content-Type"] = "application/x-www-form-urlencoded"  
  
 params.body = nil  
 query="?where="..urlencode(value.encode(obj))  
 network.request( "https://api.parse.com/1/classes/messages"..query, "GET", networkListener, params)  

Replace messages with the Parse class you use.
And obj refers to an object you created that corresponds with how your Parse class is defined. In my case, we had a class called message with fields such as “to” and I would create an object as such:

 local obj={}  
 obj.to=name  

So our query looked for messages “to” a user.

Full disclosure: AppRever does not use Parse.com but I have used this in other test code.

[import]uid: 233042 topic_id: 36453 reply_id: 144729[/import]

That works! For future reference the the first example needs a “=” after the where, so its “?where=”

Thanks again much appreciated

[import]uid: 137150 topic_id: 36453 reply_id: 144770[/import]

Thanks! That will help me out later when I get to this component of Parse. [import]uid: 94868 topic_id: 36453 reply_id: 144791[/import]

Haven’t actually tried this feature out yet, but have you tried:

[code]
local json = require (“json”)
local url = require(“socket.url”)

local dataTable = {}
dataTable[“AccessKey”] = accessKey

params.headers[“Content-Type”] = “application/json”
params.body = nil

local baseString = baseUrl … className … “/?where” … url.escape(json.encode(dataTable))

network.request( baseString, “GET”, networkListener, params)
[/code] [import]uid: 94868 topic_id: 36453 reply_id: 144723[/import]

Screaming Leaf is right.

This form works (pretty much the same thing):

 -- Use your usual headers plus the following:  
 headers["Content-Type"] = "application/x-www-form-urlencoded"  
  
 params.body = nil  
 query="?where="..urlencode(value.encode(obj))  
 network.request( "https://api.parse.com/1/classes/messages"..query, "GET", networkListener, params)  

Replace messages with the Parse class you use.
And obj refers to an object you created that corresponds with how your Parse class is defined. In my case, we had a class called message with fields such as “to” and I would create an object as such:

 local obj={}  
 obj.to=name  

So our query looked for messages “to” a user.

Full disclosure: AppRever does not use Parse.com but I have used this in other test code.

[import]uid: 233042 topic_id: 36453 reply_id: 144729[/import]

That works! For future reference the the first example needs a “=” after the where, so its “?where=”

Thanks again much appreciated

[import]uid: 137150 topic_id: 36453 reply_id: 144770[/import]

Thanks! That will help me out later when I get to this component of Parse. [import]uid: 94868 topic_id: 36453 reply_id: 144791[/import]

Haven’t actually tried this feature out yet, but have you tried:

[code]
local json = require (“json”)
local url = require(“socket.url”)

local dataTable = {}
dataTable[“AccessKey”] = accessKey

params.headers[“Content-Type”] = “application/json”
params.body = nil

local baseString = baseUrl … className … “/?where” … url.escape(json.encode(dataTable))

network.request( baseString, “GET”, networkListener, params)
[/code] [import]uid: 94868 topic_id: 36453 reply_id: 144723[/import]

Screaming Leaf is right.

This form works (pretty much the same thing):

 -- Use your usual headers plus the following:  
 headers["Content-Type"] = "application/x-www-form-urlencoded"  
  
 params.body = nil  
 query="?where="..urlencode(value.encode(obj))  
 network.request( "https://api.parse.com/1/classes/messages"..query, "GET", networkListener, params)  

Replace messages with the Parse class you use.
And obj refers to an object you created that corresponds with how your Parse class is defined. In my case, we had a class called message with fields such as “to” and I would create an object as such:

 local obj={}  
 obj.to=name  

So our query looked for messages “to” a user.

Full disclosure: AppRever does not use Parse.com but I have used this in other test code.

[import]uid: 233042 topic_id: 36453 reply_id: 144729[/import]

That works! For future reference the the first example needs a “=” after the where, so its “?where=”

Thanks again much appreciated

[import]uid: 137150 topic_id: 36453 reply_id: 144770[/import]

Thanks! That will help me out later when I get to this component of Parse. [import]uid: 94868 topic_id: 36453 reply_id: 144791[/import]

Managed to figure it out. 

_____________

I know this is an old thread - had great help from it, using the:

query="?where="…urlencode(value.encode(obj))
network.request( “https://api.parse.com/1/classes/messages”…query, “GET”, networkListener, params)

But I can’t figure out how to make compound queries, following the Parse-doc below. Haven’t been able fo find any forum thread that with a solution either. Very thankful if anyone can give me some advise.

curl -X GET \

  -H “X-Parse-Application-Id: 7bGlUVRNAUeEoO7OJoxKk6OaXneT2ckXX1D609Qx” \

  -H “X-Parse-REST-API-Key: X43mXp3WwUUeGqTwlXSvS2rh226HVBpYirdgEvbc” \

  -G \

  --data-urlencode ‘where={"$or":[{“wins”:{"$gt":150}},{“wins”:{"$lt":5}}]}’ \

  https://api.parse.com/1/classes/Player

Managed to figure it out. 

_____________

I know this is an old thread - had great help from it, using the:

query="?where="…urlencode(value.encode(obj))
network.request( “https://api.parse.com/1/classes/messages”…query, “GET”, networkListener, params)

But I can’t figure out how to make compound queries, following the Parse-doc below. Haven’t been able fo find any forum thread that with a solution either. Very thankful if anyone can give me some advise.

curl -X GET \

  -H “X-Parse-Application-Id: 7bGlUVRNAUeEoO7OJoxKk6OaXneT2ckXX1D609Qx” \

  -H “X-Parse-REST-API-Key: X43mXp3WwUUeGqTwlXSvS2rh226HVBpYirdgEvbc” \

  -G \

  --data-urlencode ‘where={"$or":[{“wins”:{"$gt":150}},{“wins”:{"$lt":5}}]}’ \

  https://api.parse.com/1/classes/Player