Help with PUT to Quiz API – 400 JSON Binding Error
I am doing testing on removing our due dates from assignments and quizzes. Upon accessing our assignments, i am able to copy the GET request, paste it into body/raw, and PUT my changes. But when i do it with our Quizzes i keep getting a 400 Error.
(all of this information in this quiz is a placeholder for my sandbox)
GET https://[sandbox-domain]/d2l/api/le/1.46/7700/quizzes/14618
{
"Name": "QUIZ3",
"IsActive": false,
"AutoExportToGrades": false,
"IsAutoSetGraded": true,
"Instructions": {
"Text": {
"Text": "",
"Html": ""
},
"IsDisplayed": false
},
"Description": {
"Text": {
"Text": "",
"Html": ""
},
"IsDisplayed": true
},
"StartDate": null,
"EndDate": null,
"DueDate": null,
"DisplayInCalendar": false,
"SortOrder": 3,
"SubmissionTimeLimit": {
"IsEnforced": false,
"ShowClock": false,
"TimeLimitValue": 0
},
"SubmissionGracePeriod": 0,
"LateSubmissionInfo": {
"LateSubmissionOption": 0
},
"AttemptsAllowed": {
"IsUnlimited": false,
"NumberOfAttemptsAllowed": 1
},
"AllowHints": false,
"DisableRightClick": false,
"DisablePagerAndAlerts": false,
"RestrictIPAddressRange": [],
"CalcTypeId": 1,
"PreventMovingBackwards": false,
"Shuffle": false,
"AllowOnlyUsersWithSpecialAccess": false,
"IsRetakeIncorrectOnly": false,
"PagingTypeId": 0,
"IsSynchronous": false
}
Upon pasting this back into the body/raw and making NO CHANGES to any value, i am met with this error:
{
"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."
}
Now i have an understanding that some values, such as boolean values, may need to be defined as True or False instead of null. I have gone through and tried to change a few of them to no avail. Ive tried removing the quiz id to the PUT field.
I’ve confirmed my token has quizzing:quizzes:read
and write scopes, and I have the appropriate permissions for this OrgUnit.
Answers
-
Hello,
Firstly, using the exact formatting from your GET will not work in many cases like this. It's pretty important that you always look back to the documentation provided online by D2L for what a PUT or POST requires. Here's a direct link to the documentation for updating or creating a new Quiz:
In particular it sounds like you are not formatting the various composite:RichTextInput values.
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"
}You will need to use this formatting for Instructions > Text, Description > Text, Header > Text, and Footer > Text.
Hope this helps!
- Nathan
-
I appreciate your response, and i did end up getting it working after more research into RichTextInput!