如何发送带空格的POST请求?

I'm trying to send input from an edittext to PHP. If I send in something with no spaces it works ok, but crashes with spaces and says this:

illegal character

...which refers to the space.

Obviously it's a matter of getting the quotes correct but for some reason I just can't get this right.

Where do I add the quotes?

Is it in Java during creating the URL?

http://example.com/android/project_group_notes_details.php?course=\'"+sessionCourse+"\'";

or while creating the Variable?

String sessionCouse = "\'Software Development With Spaces\'";

or is it somehow done server side?

A standard browser takes any spaces entered into the address bar and replaces them with %20; HTML's space character.

HTTP does not do this, the browser does, meaning that you have two options:

  1. Create a function to take in a string and replace all spaces with %20;
  2. Manually replace spaces with %20

For example:

String sessionCouse = "\'Software Development With Spaces\'";

should actually be

String sessionCouse = "\'Software%20Development%20With%20Spaces\'";

When communicating with a backend server programmatically you should use URL encode to encode you input properly:

String fullURL = "http://example.com/android/project_group_notes_details.php?course=\'"+ URLEncoder.encode(sessionCouse, "UTF-8") + "\'";