Issues with query parameter and $gt

I’m trying to do an API call that has $gt as a query parameter. This works fine either from the API Console in Kinvey or from Postman, however when I try doing this using a Java HttpURLConnection then I’m getting a 400 response: Your browser sent an invalid request.

Here’s what the query looks like:
appdata/myapp/Summary?query={ “code”:“043”, “time”: { “$gt”: 0 } }

In Java I’ve also tried encoding the dollar sign:
appdata/myapp/Summary?query={ “code”:“043”, “time”: { “%24gt”: 0 } }

If I remove that gt query parameter then it works fine.

Any ideas?

Instead of translating your URL by hand, you might try using and see what that gets you.

1 Like

I did try that already and didn’t have any luck. I tried using the encoder for the whole string as well as just the query part but I got the exact same problem.

It was the spaces. For some reason the HttpURLConnection had trouble with them. Once I removed every space in the string it started working.


It is funny that white spaces are an issue with $gt but not when

It is also funny that

does not encode the white space correctly.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.