title: How to pass long string in HttpClient.PostAsync request
body: <p>Trying to send a rather long string to a REST web api (youtrack). I get the following exception:</p>
  
  <p>Invalid URI: The Uri string is too long.</p>
  
  <p>My code:</p>
  
  <pre><code>var encodedMessage = HttpUtility.UrlEncode(message);
  var requestUri = string.Format("{0}{1}issue/{2}/execute?comment={3}", url, YoutrackRestUrl, issue.Id, encodedMessage);
  var response = await httpClient.PostAsync(requestUri, null).ConfigureAwait(false);
  </code></pre>
  
  <p>So I took my chances with a <code>FormUrlEncodedContent</code></p>
  
  <pre><code>var requestUri = string.Format("{0}{1}issue/{2}/execute", url, YoutrackRestUrl, issue.Id);
  
  var postData = new List&lt;KeyValuePair&lt;string, string&gt;&gt;();
  postData.Add(new KeyValuePair&lt;string, string&gt;("comment", message));
  
  var content = new FormUrlEncodedContent(postData);
  var response = await httpClient.PostAsync(requestUri, content).ConfigureAwait(false);
  </code></pre>
  
  <p>Which results in the exact same issue.</p>
  
  <p>The string (comment) I am sending, is the changed file set of a commit into SVN. Which can be really long, so I don't really have a way to get around that. Is there a way to post content without the string length restriction?</p>
  
  <p>Read the following topics, but didn't find an answer there:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/15176538/net-httpclient-how-to-post-string-value">.NET HttpClient. How to POST string value?</a></li>
  <li><a href="https://stackoverflow.com/questions/18971510/how-do-i-set-up-httpcontent-for-my-httpclient-postasync-second-parameter">How do I set up HttpContent for my HttpClient PostAsync second parameter?</a></li>
  <li><a href="https://psycodedeveloper.wordpress.com/2014/06/30/how-to-call-httpclient-postasync-with-a-query-string/" rel="nofollow noreferrer">https://psycodedeveloper.wordpress.com/2014/06/30/how-to-call-httpclient-postasync-with-a-query-string/</a></li>
  <li><a href="http://forums.asp.net/t/2057125.aspx?Invalid+URI+The+Uri+string+is+too+long+HttpClient" rel="nofollow noreferrer">http://forums.asp.net/t/2057125.aspx?Invalid+URI+The+Uri+string+is+too+long+HttpClient</a></li>
  </ul>