Search code examples
iosdesire2learn

Desire2Learn: How Can i attach the file with New Post in Discussions?


I can create a new post in Discussions using the following feed

Feed: host/d2l/api/le/(D2LVERSION: version)/(D2LID: orgUnitId)/discussions/forums/(D2LID: forumId)/topics/(D2LID: topicId)/posts/
Content-Type:"application/json"
http-Metohd:POST

 http-body:{
    "ParentPostId": null,
    "Subject": "IOS  Testing",
    "Message": {"Content": "ios Test meassage","Type": "Text"},
    "IsAnonymous": "false"
 }

How can i attach the file with this?


Solution

  • The API does not provide a way to upload files to an existing discussion post. Once created, you can only update the post's Subject and Message components.

    To create a new discussion post with attachments, you send a multipart-post body. The first part in the body should be your post's data as in your example. Subsequent parts can contain the file data for one or more attachments and should follow the RFC2388 multi-part mixed methodology (because the first part is JSON data, and the subsequent part(s) are binary data).