title: Posting to a REST webservice from .NET?
body: <p>I was trying to hit a web service using the instructions here:</p>
  
  <p><a href="http://help.seeclickfix.com/kb/api/creating-an-issue" rel="nofollow">http://help.seeclickfix.com/kb/api/creating-an-issue</a></p>
  
  <p>I came up with the code below:</p>
  
  <pre><code>        string paramContent = "api_key=afs684eas3ef86saef78s68aef68sae&amp;issue[summary]=abeTest&amp;issue[lat]=39.26252982783172&amp;issue[lng]=-121.01738691329956&amp;issue[address]=111 Abe St., Nevada City, CA";
          byte[] paramBytes = Encoding.UTF8.GetBytes(paramContent);
          HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://seeclickfix.com/api/issues.xml");
          req.Method = "POST";
          req.ContentLength = paramBytes.Length;
          //req.ContentType = "application/x-www-form-urlencoded";
  
          using (Stream reqStream = req.GetRequestStream())
          {
              reqStream.Write(paramBytes, 0, paramBytes.Length);
          }
  
          using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) //HERE!
          {
              if (resp.StatusCode != HttpStatusCode.OK)
              {
                  string message = String.Format("POST failed. Received HTTP {0}", resp.StatusCode);
                  throw new ApplicationException(message);
              }
  
              StreamReader sr = new StreamReader(resp.GetResponseStream());
              string response = sr.ReadToEnd();
  
              Console.WriteLine(response + System.Environment.NewLine);
          }
  </code></pre>
  
  <p>But at the line with the <code>HERE!</code> comment it throws the error:</p>
  
  <pre><code>The remote server returned an error: (500) Internal Server Error.
  </code></pre>
  
  <p>Can anyone see any problems with the way I am trying to implement this?</p>