Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The documentation doesn't say it explicitly, but the attachment itself is bundled into the request as multipart/form-data.</p> <p>The best way to debug what's going on is use Fiddler to watch the request. Make sure you accept Fiddler's root certificate, or the request won't issue due to the SSL error.</p> <p>What you should see in Fiddler is for Headers:</p> <p>Cookies / Login</p> <pre><code>Authorization: Basic &lt;snip&gt;== </code></pre> <p>Entity</p> <pre><code>Content-Type: multipart/form-data; boundary=&lt;num&gt; </code></pre> <p>And for TextView:</p> <pre><code>Content-Disposition: form-data; name="attachment" @Test.pdf Content-Disposition: form-data; name="attachment"; filename="Test.pdf" Content-Type: application/pdf &lt;data&gt; </code></pre> <p>Note that you POST the field 'attachment=@&lt;filename>'. For form-data, the field name is also 'attachment', then has 'filename=&lt;filename>' (without the '@') and finally the file contents.</p> <p>I think CURL is supposed to just do this all for you magically based on using the '@' syntax and specifying a path to a file on your local machine. But without knowing the magic behavior it's hard to grok what's really happening.</p> <p>For example, in C# it looks like this:</p> <pre><code>public static void SendMail(MailMessage message) { RestClient client = new RestClient(); client.BaseUrl = apiUrl; client.Authenticator = new HttpBasicAuthenticator("api", apiKey); RestRequest request = new RestRequest(); request.AddParameter("domain", domain, ParameterType.UrlSegment); request.Resource = "{domain}/messages"; request.AddParameter("from", message.From.ToString()); request.AddParameter("to", message.To[0].Address); request.AddParameter("subject", message.Subject); request.AddParameter("html", message.Body); foreach (Attachment attach in message.Attachments) { request.AddParameter("attachment", "@" + attach.Name); request.AddFile("attachment", attach.ContentStream.WriteTo, attach.Name, attach.ContentType.MediaType); } ... request.Method = Method.POST; IRestResponse response = client.Execute(request); } </code></pre>
    singulars
    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. This table or related slice is empty.
    1. VO
      singulars
      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