I have the following architecture:
- mobile client connecting to the Google App Engine (Java) application
- GAE retrieves information from a Firebase database using a REST call
Since the Firebase Admin SDK does not work with GAE due to background threads, I decided to use the Firebase REST API. Everything goes well when I update the Firebase database or get something from a specific path, but when I want to filter the data, I have a problem.
When executing the cUrl request, everything works fine:
curl -X GET \ -H 'Authorization: Bearer auth_token' \ 'https://my_project.firebaseio.com/items.json?orderBy="$value"&equalTo="some_string"'
But when I execute the exact same request using HttpURLConnection or URLFetchService from java code in my GAE application, I get strange errors. At first these were urlencoding errors, so I had to change my url to something like this:
https://my_project.firebaseio.com/items.json?orderBy=%22%24value%22&equalTo=%22some_string%22
But even after that I get 400 error codes with the following message:
{"error": "orderBy must be determined when defining other request parameters"}
My request code is as follows:
URL url = URL(urlString); HTTPRequest request = HTTPRequest(url, HTTPMethod.GET, opts) request.addHeader(HTTPHeader(AUTH_HEADER, "Bearer " + accessToken)); HTTPResponse responseRaw = service.fetch(request);
I tried to use different values as urlString (just assigning a string to a variable) without vail:
String urlString = "https://my_project.firebaseio.com/items.json?orderBy=%22%24value%22&equalTo=%22some_string%22"; String urlString = "https://my_project.firebaseio.com/items.json?orderBy=%22$value%22&equalTo=%22some_string%22"; String urlString = "https://my_project.firebaseio.com/items.json?orderBy=\"$value\"&equalTo=\"some_string\"";
The third value threw an exception and no request was sent. Which removes the equalTo parameter more, makes the request work, I get 200 and json in response:
String urlString = "https://my_project.firebaseio.com/items.json?orderBy=%22$value%22";
Any idea what I'm doing wrong?