java - Parse "no results found for query (code 101)". Can't get object id -
i've installed example parse server (https://github.com/parseplatform/parse-server-example) on desktop , made simple app test it.
my app saves object server, gets object , sets mtextview's value value of object.
the problem is, when try code data server works:
query.getinbackground("5k7n8a8dmd", new getcallback<parseobject>() ...
(got object id curl)
but when try (to object id w/o using curl):
gamescore.saveinbackground(new savecallback() { public void done(parseexception e) { if (e == null) { objectid = gamescore.getobjectid(); } else { log.e("saveinbackground", geterrormessage(e)); } } }); ... query.getinbackground(objectid, new getcallback<parseobject>() ...
it doesn't work.
logcat:
e/getinbackground﹕ no results found query - code: 101
mainactivity.java
public class mainactivity extends activity { public textview mtextview; public string objectid; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mtextview = (textview) findviewbyid(r.id.text_view); parse.initialize(new parse.configuration.builder(getapplicationcontext()) .applicationid(constants.app_id) .server(constants.server_url) .build() ); final parseobject gamescore = new parseobject("foo1234"); gamescore.put("score", 5000); gamescore.saveinbackground(new savecallback() { public void done(parseexception e) { if (e == null) { objectid = gamescore.getobjectid(); } else { log.e("saveinbackground", geterrormessage(e)); } } }); parsequery<parseobject> query = parsequery.getquery("foo1234"); query.getinbackground(objectid, new getcallback<parseobject>() { public void done(parseobject object, parseexception e) { if (e == null) { mtextview.settext(integer.tostring(gamescore.getint("score"))); } else { log.e("getinbackground", geterrormessage(e)); } } }); } public string geterrormessage(parseexception e) { return e.getmessage() + " - code: " + e.getcode(); } }
constants.java
public class constants { public static string server_url = "http://192.168.1.14:1337/parse/"; public static string app_id = "myappid"; }
thanks in advance.
try this
parsequery<parseobject> query = parsequery.getquery("_foo1234"); query.whereequalto("objectid","wfbb0gpckp"); query.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> objects, parseexception e) { if (e == null) { // row of object id "wfbb0gpckp" } else { // error } } });
also change
parsequery<parseobject> query = parsequery.getquery("foo1234");
to
parsequery<parseobject> query = parsequery.getquery("_foo1234");
see if works.
Comments
Post a Comment