Unable to create a Grade.GradeObject using OAuth 2.0 API

Options
Tarun.Malhotra6998
Tarun.Malhotra6998 Posts: 3 🌱
edited November 2022 in Development

While trying to create a create a gradeObject (POST /d2l/api/le/(version)/(orgUnitId)/grades/) using the API vide OAuth 2.0, I receive the following 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."

}

 

Input JSON

 

{

 "MaxPoints": 2.0,

 "CanExceedMaxPoints": false,

 "CategoryId": null,

 "Name": "SoomoChapter2",

 "ShortName": "sgc2",

 "GradeType": "Numeric",

 "GradeSchemeId": null,

 "IsBonus": false,

 "ExcludeFromFinalGradeCalculation": false

}

 

However, I am able to use the API vide OAuth 2.0 (GET /d2l/api/le/(version)/(orgUnitId)/grades/(gradeObjectId)) to retrieve a gradeObject created using the UI

 

{

  "MaxPoints": 10.000000000,

  "CanExceedMaxPoints": false,

  "IsBonus": false,

  "ExcludeFromFinalGradeCalculation": false,

  "GradeSchemeId": null,

  "GradeSchemeUrl": "/d2l/api/le/1.26/6972/grades/schemes/3",

  "Id": 445,

  "Name": "Soomo Chapter 1",

  "ShortName": "soomo_chapter_1",

  "GradeType": "Numeric",

  "CategoryId": 0,

  "Description": {

   "Text": "",

   "Html": ""

  },

  "Weight": 10.000000000,

  "AssociatedTool": null

 }

 

Any inputs of what am I doing wrong here?

 

Thanks!

Tagged:

Answers

  • Maja.Kokotovic5767
    edited November 2022
    Options

    Hey @Tarun Malhotra​ !

     

    Looking at the JSON you're passing through and the relevant documentation (http://docs.valence.desire2learn.com/res/grade.html#Grade.GradeObject), I can see that you're missing two JSON parameters:

     

    • Description
    • Associated Tool

     

    Could you please try updating your JSON so that it looks like this:

     

    {

    "MaxPoints":2.0,

    "CanExceedMaxPoints":true,

    "IsBonus":false,

    "ExcludeFromFinalGradeCalculation":false,

    "GradeSchemeId":null

    "Name":"SoomoChapter2",

    "ShortName":"soomo_chapter_1",

    "GradeType":"Numeric",

    "CategoryId":null,

    "Description":{"Content":"Description","Type":"Text"}, 

    "AssociatedTool":null

    }

     

    Try it out and let us know if it works!

     

    Maja

  • Tarun.Malhotra6998
    Tarun.Malhotra6998 Posts: 3 🌱
    edited November 2022
    Options

    Hey @Maja Kokotovic​ 

     

    I tried your suggestion as above, but am still getting the same error. Attached herewith is a screenshot illustrating the error!

    restclient_brightpsace_error

    Tarun

  • David Wag207
    David Wag207 Posts: 17
    edited November 2022
    Options

    Hey @Tarun Malhotra​,

     

    I think your input JSON is just missing a comma after the GradeSchemeId. The following should work for you:

     

    {

    "MaxPoints":2.0,

    "CanExceedMaxPoints":true,

    "IsBonus":false,

    "ExcludeFromFinalGradeCalculation":false,

    "GradeSchemeId":null,

    "Name":"SoomoChapter2",

    "ShortName":"soomo_chapter_1",

    "GradeType":"Numeric",

    "CategoryId":null,

    "Description":{"Content":"Description","Type":"Text"}, 

    "AssociatedTool":null

    }

     

    Hope that works for you,

    Dave

     

  • Tarun.Malhotra6998
    Tarun.Malhotra6998 Posts: 3 🌱
    edited November 2022
    Options

    Hey @_David _Wagler​ 

     

    Thanks this works :-)

     

    Tarun

  • Maja.Kokotovic5767
    edited November 2022
    Options

    Whoops! Sorry about that, @Tarun Malhotra​  :)

     

    Thanks, @_David _Wagler​!

     

    Maja