Problems using PUT with /d2l/api/le/(version)/(orgUnitId)/content/modules/(moduleId) endpoint
Hi,
I'm trying to use the PUT method with /d2l/api/le/(version)/(orgUnitId)/content/modules/(moduleId) endpoint. According to Brightspace API Reference, the payload shoul be a ContentObjectData, with the following fields:
{
"Title": <string>,
"ShortTitle": <string>,
"Type": 0,
"ModuleStartDate": <string:UTCDateTime>|null,
"ModuleEndDate": <string:UTCDateTime>|null,
"ModuleDueDate": <string:UTCDateTime>|null,
"IsHidden": <boolean>,
"IsLocked": <boolean>,
"Description": { <composite:RichTextInput> }|null,
"Duration": <number>|null // Available in LE's unstable contract
}
And RichTextInput is:
{
"Content": <string>,
"Type": "Text/Html"
}
I tried calling the API with different parameter values, including default values (i.e. null, true, false or ""), but I always receive a status code 400 with the following response:
{
"type": "http://docs.valence.desire2learn.com/res/apiprop.html#json-binding-error",
"title": "JSON Binding Error",
"status": 400,
"detail": "Provided JSON is invalid or does not match the expected format."
}
The payload I'm using is (in Python):
data = {
"Title":" <string>",
"ShortTitle": "<string>",
"Type": 0,
"ModuleStartDate": None,
"ModuleEndDate": None,
"ModuleDueDate": None,
"IsHidden": False,
"IsLocked": False,
"Description": None,
"Duration": None
}
When I call the same endpoint with GET method, everything works fine.
Does anyone have any clue?
Thks,
Gerson
Answers
-
Hi Gerson,
Thank you for reaching out to the Brightspace Community!
I have made some changes to the JSON block including the Description field. Could you please try this in your PUT call again and let me know if it helps resolve the issue?
{"Title": "Please enter title name","ShortTitle": "Short description of the title","Type": 0,"ModuleStartDate": null,"ModuleEndDate": null,"ModuleDueDate": null,"IsHidden": false,"IsLocked": false,"Description": {"Content": "", "Type": "Text"},"Duration": null}
Thanks,
Unaib

