我正在使用解析服务器后端并在JAVA(Libgdx)中开发我的前端。
我可以在没有如下参数的情况下检索简单查询的结果:
HttpRequest httpGet = new HttpRequest(HttpMethods.GET);
httpGet.setUrl("https://parseapi.back4app.com/classes/MESSAGE/");
httpGet.setHeader("Content-Type", "application/json");
httpGet.setHeader("X-Parse-Application-Id", app_id);
httpGet.setHeader("X-Parse-REST-API-Key", app_key);
Gdx.net.sendHttpRequest(httpGet,Parse.this);
但我没有设法使用限制条件。我尝试将参数放入查询中,但没有成功:
HttpRequest httpGet = new HttpRequest(HttpMethods.GET);
String params = "where={\"username\":\"unknown\"}";
String encoded="";
try {
encoded=URLEncoder.encode(params,"utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
httpGet.setUrl("https://parseapi.back4app.com/classes/MESSAGE/");
httpGet.setHeader("Content-Type", "application/json");
httpGet.setHeader("X-Parse-Application-Id", app_id);
httpGet.setHeader("X-Parse-REST-API-Key", app_key);
httpGet.setContent(encoded);
Gdx.net.sendHttpRequest(httpGet,Parse.this);
我还尝试将参数(UTF-8编码)直接放入url;它也没有工作。(如同这个问题https://www.parse.com/questions/how-to-interpret-rest-api-without-data-url-encode)
(解析服务器REST API文档https://parseplatform.github.io/docs/rest/guide/#query-constraints)
如果你们有任何想法,我会非常感激, 提前谢谢!