REST API Create thread doesn't save attachment

Developer Space

Developer Space
Want to extend the Telligent Evolution platform? Collaborate with other developers and product experts here.

REST API Create thread doesn't save attachment

This question has suggested answer(s)

I'm creating a new Thread with the REST API endpoint  api.ashx/v2/forums/31/threads.xml - the data is being sent as multipart/form-data and everything works except attachments. The body of the POST request is below. There are no errors or warnings reported. What am I doing wrong?

Content-Disposition: form-data; name="ForumId"

Content-Disposition: form-data; name="Subject"

Nuther attacvhment
Content-Disposition: form-data; name="MarkAsRead"

Content-Disposition: form-data; name="Body"


Content-Disposition: form-data; name="ContentType"

Content-Disposition: form-data; name="FileName"

Content-Disposition: form-data; name="FileData"

This file contains text only

All Replies
  • What version of the platform are you using, and can you share the the complete REST trace?


  • testattachment.txt

    I've attached a log file. This is a hand-crafted test, but the result is the same when I create a thread in my application.

  • As in this example,, you should send the file name and content type within the header of the file's content when using a multipart form data content type for your request.

  • The example you linked to is not applicable to attachments to the forum Thread and Reply endpoints. These specify the use of a "FileData" element to hold the binary file data, not the "file" element in the example. The linked-to example does work for other endpoints, and I have been able to use the apparently undocumented multifileupload.ashx endpoint to create a FileUploadContext which then does work in a Thread or Reply endpoint. But sending binary file data in a Thread endpoint (in the FileData element) results in corruption of the file, specifically bytes with high bit set are replaced with other bytes.

    The FileUploadContext argument is mentioned in several REST endpoints (e.g. user avatar as well as Thread and Replies) but there is nothing in the documentation that I can find that specifies where to get one from. I found the multifileupload.ashx endpoint only by sniffing the web UI.

  • The example is applicable.  REST interprets file uploads differently depending on how the request is formatted.  All endpoints supporting file uploading support working as in the example.

    FileUploadContext is exposed to widgets, primarily, via the fileUpload and multipleUpload jQuery plugins.  It is an optimization enabling widgets to save attachments more directly.

    While it can be used by external applications, the multiplefileupload.ashx handler is not directly supported.