Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is cut and pasted from some sample code I wrote, hopefully it should give the basics. It only supports File data and form-data at the moment.</p> <pre><code>public class PostData { private List&lt;PostDataParam&gt; m_Params; public List&lt;PostDataParam&gt; Params { get { return m_Params; } set { m_Params = value; } } public PostData() { m_Params = new List&lt;PostDataParam&gt;(); // Add sample param m_Params.Add(new PostDataParam("email", "MyEmail", PostDataParamType.Field)); } /// &lt;summary&gt; /// Returns the parameters array formatted for multi-part/form data /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; public string GetPostData() { // Get boundary, default is --AaB03x string boundary = ConfigurationManager.AppSettings["ContentBoundary"].ToString(); StringBuilder sb = new StringBuilder(); foreach (PostDataParam p in m_Params) { sb.AppendLine(boundary); if (p.Type == PostDataParamType.File) { sb.AppendLine(string.Format("Content-Disposition: file; name=\"{0}\"; filename=\"{1}\"", p.Name, p.FileName)); sb.AppendLine("Content-Type: text/plain"); sb.AppendLine(); sb.AppendLine(p.Value); } else { sb.AppendLine(string.Format("Content-Disposition: form-data; name=\"{0}\"", p.Name)); sb.AppendLine(); sb.AppendLine(p.Value); } } sb.AppendLine(boundary); return sb.ToString(); } } public enum PostDataParamType { Field, File } public class PostDataParam { public PostDataParam(string name, string value, PostDataParamType type) { Name = name; Value = value; Type = type; } public string Name; public string FileName; public string Value; public PostDataParamType Type; } </code></pre> <p>To send the data you then need to:</p> <pre><code>HttpWebRequest oRequest = null; oRequest = (HttpWebRequest)HttpWebRequest.Create(oURL.URL); oRequest.ContentType = "multipart/form-data"; oRequest.Method = "POST"; PostData pData = new PostData(); byte[] buffer = encoding.GetBytes(pData.GetPostData()); // Set content length of our data oRequest.ContentLength = buffer.Length; // Dump our buffered postdata to the stream, booyah oStream = oRequest.GetRequestStream(); oStream.Write(buffer, 0, buffer.Length); oStream.Close(); // get the response oResponse = (HttpWebResponse)oRequest.GetResponse(); </code></pre> <p>Hope thats clear, i've cut and pasted from a few sources to get that tidier.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload