title: Curl command to C# web api request
body: <p>I have following CURL command which I would like to translte into c# webapi call. </p>
  
  <pre><code>curl -H "Content-Type: application/x-www-form-urlencoded" \
  -H "client_id: YOUR-CLIENT-ID" \
  -H "client_secret: YOUR-CLIENT-SECRET" \
  -d "mailbox_id=YOUR-MAILBOX-ID" \
  --data-urlencode email@/path/to/email/contents.eml \
  "https://api.abc.com/v2/add"
  </code></pre>
  
  <p>The part where i need help is how to add mailbox id and data as url encoded. also it is picking up email from disk. Can I just add byte array ?</p>
  
  <p>Here is my example of c# code. 
  I only need to add mailid and email content in there. </p>
  
  <pre><code>  public static string WebRequestWithByte(byte[] postData)
      {
          var url = @"https://api.abv.com/v2/add";
          var clientId = "wewew";
          var clientSecret = "df58ffed4bc0bc41";
  
  
          string ret = string.Empty;
  
          StreamWriter requestWriter;
  
          var webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
          if (webRequest != null)
          {
              webRequest.Headers.Add("client_id", clientId);
              webRequest.Headers.Add("client_secret", clientSecret);
              webRequest.Method = "POST";
              webRequest.ServicePoint.Expect100Continue = false;
              webRequest.Timeout = 20000;
              webRequest.ContentType = "application/x-www-form-urlencoded";
              //POST the data.
              using (requestWriter = new StreamWriter(webRequest.GetRequestStream()))
              {
                  requestWriter.Write(payloadStr);
              }
          }
  </code></pre>