Creating Topics and Modules via API - working examples?
If anyone has a collection of know, working, examples across the activity types it would be much appreciated.
The more the better IMO!! Thanks in advance.
Comments
-
I tried multiple times and can not figure this out as well. I get the same error message as you do.
-
@Matt.J.517 I got it to work - I just needed the help of ChatGPT to read all the documentation and it was finally able to create the correct JSON code for the Body in Postman.
{
"Title": "Simple Module",
"ShortTitle": "Module", // Optional, can be empty or null
"Type": 0,
"ModuleStartDate": null, // Optional, can be set to a UTC DateTime string if needed
"ModuleEndDate": null, // Optional, can be set to a UTC DateTime string if needed
"ModuleDueDate": null, // Optional, requires LE API v1.70 or higher if setting a due date
"IsHidden": false, // Optional, set true if you want the module hidden by default
"IsLocked": false, // Optional, set true if you want the module locked
"Description": {
"Text": "Module description text",
"Html": "<p>Module description text</p>"
},
"Duration": null // Optional, set to an integer for minutes if using unstable contract
}
Explanation of Fields:- Title: Required; a non-empty string for the module’s title.
- ShortTitle: Optional; can be an empty string or
null
. - Type: Required; must be
0
for modules. - ModuleStartDate, ModuleEndDate, ModuleDueDate: Optional; if provided, these should be in UTC DateTime format (e.g.,
"2024-10-20T00:00:00Z"
). - IsHidden, IsLocked: Optional;
true
orfalse
values to control visibility and locking. - Description: Optional; uses the
RichTextInput
structure withText
andHtml
fields. - Duration: Optional; if your environment uses LE's unstable contract, specify minutes required to cover the module.
Important Notes:
- UTC Date Format: If you need to set
ModuleStartDate
,ModuleEndDate
, orModuleDueDate
, use a valid UTC format, e.g.,"2024-10-20T00:00:00Z"
. - Description Format: The
Description
field should use bothText
andHtml
keys for text and HTML content. - Token Permissions: Ensure the API token has the
content:modules:manage
scope.
-
thanks @Justin.B.253 how did you get on with Topics? Modules are a good start but then you move into topics and then you'll see how much more is required to get going! Adding a weblink is ok - adding a Forum is a beast.
-
@Matt.J.517 It took a bit of time only because I was trying to send data to the wrong course, but I was able to get the topic with a link to work. I haven't been successful with creating a file (HTML page) or linking to a file like a .pdf document.
With a link -
{ "Title": "Sample Topic", "ShortTitle": "Sample", "Type": 1, "TopicType": 3, "Url": "https://example.com", "StartDate": null, "EndDate": null, "DueDate": null, "IsHidden": false, "IsLocked": false, "OpenAsExternalResource": true, "Description": { "Text": "This is a sample topic description", "Html": "<p>This is a sample topic description</p>" }, "MajorUpdate": true, "MajorUpdateText": "Sample Topic Updated", "ResetCompletionTracking": true, "Duration": 30}
I'll play with Discussion Boards as well.