title: How to generate URL containing JSON as parameter for the GET action
body: <p>I have the following curl command that works well to retrieve a list of json objects from my Parse.com project.</p>
  
  <pre><code>curl -X GET -H "X-Parse-Application-Id: {MY_APP_ID}" -H "X-Parse-REST-API-Key: {MY_REST_API}" -H "X-Parse-Session-Token: {MY_SESSION_TOKEN}" -G --data-urlencode "where={\"$relatedTo\":{\"object\":{\"__type\":\"Pointer\",\"className\":\"_Role\",\"objectId\":\"{MY_OBJECT_ID}\"},\"key\":\"users\"}}" https://api.parse.com/1/users
  </code></pre>
  
  <p>Now I want to create a Java Servlet to do the same thing with HttpURLConnection. I created the following URL:</p>
  
  <pre><code>String url = "https://api.parse.com/1/users?where={\"$relatedTo\":{\"object\":{\"__type\":\"Pointer\",\"className\":\"_Role\",\"objectId\":\"{MY_OBJECT_ID}\"},\"key\":\"users\"}}"
  
  URL object = new URL(strUrl);
  
  HttpURLConnection connection = (HttpURLConnection) object
                  .openConnection();
  
  connection.setDoOutput(true);
  connection.setDoInput(true);
  connection.setRequestMethod("GET");
  connection.setRequestProperty("X-Parse-Application-Id", APP_ID);
  connection.setRequestProperty("X-Parse-REST-API-Key", REST_API_KEY);
  connection.setRequestProperty("X-Parse-Session-Token", sessionToken);
  connection.setRequestProperty("Content-Type", "application/json");
  </code></pre>
  
  <p>Then I ended up with getting an error:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Illegal character in query at index 36: https://api.parse.com/1/users?where={"$relatedTo":{"object":{"__type":"Pointer","className":"_Role","objectId":"{MY_OBJECT_ID}"},"key":"users"}}
  </code></pre>
  
  <p>I am kind of sure that it's the URL that threw out the error. But no idea how to fix it. Thanks!</p>