Discussions API Issue: Unable to create a topic under forums ?
I'm able to create a forum successfully but unable to create a topic, could you please help me what went wrong here.
POST /d2l/api/le/(version)/(orgUnitId)/discussions/forums/
Create a new forum for an org unit. - Successful
Response: {
"ForumId": 39,
"Name": "New Post 2",
"Description": {
"Text": "Forum description 2",
"Html": "<p>Forum description 2</p>"
},
"ShowDescriptionInTopics": true,
"AllowAnonymous": false,
"IsLocked": false,
"IsHidden": false,
"RequiresApproval": false,
"MustPostToParticipate": true,
"DisplayInCalendar": false,
"DisplayPostDatesInCalendar": false,
"StartDate": null,
"EndDate": null,
"PostStartDate": null,
"PostEndDate": null,
"StartDateAvailabilityType": null,
"EndDateAvailabilityType": null
}
POST /d2l/api/le/(version)/(orgUnitId)/discussions/forums/(forumId)/topics/
Create a new topic for the provided discussion forum in an org unit. - failed getting 400 error.
Request: { "Name": "Your Topic Name 39", "Description": { "Text": "Topic description 39", "Html": "<p>Topicdescription39</p>" }, "AllowAnonymousPosts":
false
, "StartDate":
null
, "EndDate":
null
, "IsHidden":
false
, "UnlockStartDate":
null
, "UnlockEndDate":
null
, "RequiresApproval":
false
, "ScoreOutOf":
null
, "IsAutoScore":
false
, "IncludeNonScoredValues":
false
, "ScoringType":
null
, "IsLocked":
false
, "MustPostToParticipate":
true
, "RatingType":
null
, "DisplayInCalendar":
null
, "DisplayUnlockDatesInCalendar":
null
, "GroupTypeId":
null
, "StartDateAvailabilityType":
null
, "EndDateAvailabilityType":
null
}
Note: Most of the API's are working except creating topic.
Answers
-
Hello!
I believe the issue is your "Description" value. The format you are attempting to use is what the GET call returns but it's not what the POST call requires.Whenever you see a { composite:RichTextInput } field in a JSON example, that stands in for a composite block like this:
{
"Content": <string>,
"Type": "Text|Html"
}So I believe you would want to try something like:
{
"Content": "<p>Forum description 2</p>",
"Type": "Html"
}