Showing results for 
Search instead for 
Did you mean: 
Community Member

API PUT request does nothing

I'm trying to use the Canvas API through Google Apps Script to send students scores in for the classes I teach. Currently, I'm attempting to use the "Grade or comment on a submission" documented here. I know that my URL is set up correctly as I can test out API calls using Canvas' live API feature. The response code comes back as 200 however the student's grade remains unchanged.

Here's the code I'm using:




      var url = ""+getcourseid()+"/assignments/"+assignmentid+"/submissions/"+studentid;
      var payload = JSON.stringify({
        "score": 7
      var headers = {
        "Authorization": "Bearer " + getcanvasaccesstoken()
      var options = {
        "contentType": "application/json",
        "method": "put",
        "headers": headers,
        "payload": payload, 
        "muteHttpExceptions" : true,

  var apiresponse = UrlFetchApp.fetch(url,options);





The request (using UrlFetchApp.getRequest) gives me:




headers={Authorization=Bearer <token}, 
contentType=application/json, validateHttpsCertificates=true,





Again, the response I receive back shows no change in the "score" parameter. I'm not sure if there is maybe an issue with how the payload is formatted. This works through the Canvas Live API but it doesn't show me how a similar request should be formatted only the url.

Labels (1)
0 Kudos
1 Reply
Community Champion

Hi @bunzejj,

Welcome to the Canvas Community... here is vast space, but a small world. I'm one of the Canvas Admins for CCSD and would be happy to help. It looks like the payload is submission[posted_grade], not just score.

submission[posted_grade] string Assign a score to the submission, updating both the “score” and “grade” fields on the submission record

  "submission": {
    "posted_grade": 7

I always start with the beta instance when using the API, but the assignment/submission you you are trying to edit isn't on beta yet,, so I tested this against another of your assignments and got back a 200, but with the grade changed to 7, and the score changed to 7.0, and entered_grade and entered_score also reflect the change.

Please let me know if that works for you or if you have any more questions.