title: JIRA REST API how to add attachment using c#
body: <p>I am using jira api to add attachment to the issue</p>
  <p>According to documentation i have set few things.</p>
  <ol>
  <li><p>submit a header of X-Atlassian-Token: nocheck with the request.</p>
  </li>
  <li><p>The name of the multipart/form-data parameter that contains attachments must be &quot;file&quot;.</p>
  </li>
  <li><p>resource expects a multipart post.</p>
  </li>
  </ol>
  <p>&amp; <strong>when i run my code i get internal server error.</strong></p>
  <p>my code is as follows</p>
  <pre><code>string postUrl = &quot;http://localhost:8080/rest/api/latest/issue/TES-99/attachments&quot;;
  System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); 
  client.DefaultRequestHeaders.Add(&quot;X-Atlassian-Token&quot;, &quot;nocheck&quot;);
  client.BaseAddress = new System.Uri(postUrl);
  byte[] cred = UTF8Encoding.UTF8.GetBytes(credentials);
  client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(&quot;Basic&quot;, Convert.ToBase64String(cred));
  var content = new MultipartFormDataContent();
  var values = new[]
  {
      new KeyValuePair&lt;string, string&gt;(&quot;file&quot;, &quot;e:\\z.txt&quot;)               
  };
  foreach (var keyValuePair in values)
  {
      content.Add(new StringContent(keyValuePair.Value), keyValuePair.Key);
  }
              
  var result = client.PostAsync(postUrl, content).Result;
  </code></pre>
  <p>please suggest where i am making mistake</p>