title: Send large string from Android to MVC
body: <p>I'm trying to send a very large string from android to my mvc application and back to android. Below is my codes for the MVC application.    </p>
  
  <pre><code>[HttpPost]
      public HttpResponseMessage RetrieveString(String longString)
      {
          var resp = new HttpResponseMessage()
          {
              Content = new StringContent("{\"ResultString\":\"" + longString + "\"}")
          };
          resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
          return resp;
      }
  </code></pre>
  
  <p>Here is the code for the android application</p>
  
  <pre><code>protected String doInBackground(String... params) {
  
          HttpURLConnection urlConnection = null;
          BufferedReader reader = null;
          String JSONStr = null;
  
          try {
              final String URL = "http://172.27.179.197:7837/api/TestCon/RetrieveString?";
  
              Uri builtUri = Uri.parse(URL).buildUpon()
                      .appendQueryParameter("longString", params[0]).build();
  
              URL url = new URL(builtUri.toString());
  
              urlConnection = (HttpURLConnection) url.openConnection();
              urlConnection.setRequestMethod("POST");
              urlConnection.setRequestProperty("connection", "keep-alive");
              urlConnection.setRequestProperty("Content-Type", "multipart/form-data");
              urlConnection.connect();
  
              InputStream inputStream = urlConnection.getInputStream();
              StringBuffer buffer = new StringBuffer();
              if (inputStream == null) {
                  return null;
              }
              reader = new BufferedReader(new InputStreamReader(inputStream));
  
              String line;
              while ((line = reader.readLine()) != null) {
                  buffer.append(line + "\n");
              }
  
              if (buffer.length() == 0) {
                  return null;
              }
              JSONStr = buffer.toString();
          } catch (IOException e) {
              Log.e(LOG_TAG, "Error ", e);
              return null;
          } finally {
              if (urlConnection != null) {
                  urlConnection.disconnect();
              }
              if (reader != null) {
                  try {
                      reader.close();
                  } catch (final IOException e) {
                      Log.e(LOG_TAG, "Error closing stream", e);
                  }
              }
          }
          return JSONStr;
      }
  </code></pre>
  
  <p>This codes work fine is I'm sending in short string. However, when the string get too long (hundreds or thousands of characters), the Android application throws a "java.io.FileNotFoundException: <code>http://172.27.179.197:7837/api/TestCon/RetrieveUserByEmail?inputEmail=&lt;&lt;Very Long String&gt;&gt;"</code> exception. Any advice on how to send this long string across to MVC? Thanks!</p>