javascriptgoogle-classroom

Trying to get the list of courseWork of Classroom API with javascript (error "the required parameter courseId is empty")


I am trying to get the list of courseWork for a specific course. I access an iteration of the courses and when the appropriate course arrives successfully I use the following code to get the courseWork list:

await gapi.client.classroom.courses.courseWork.list(idcourse, 
  {}).then(function(response2) 
{                            
 });

The error I get is that "the required parameter courseId is empty".

The response2 object is undefined.

idcourse is a string that is obtained in the iteration and I have verified that it is a valid and correct string.

I have tried other options like:

 await gapi.client.classroom.courses.courseWork.list( 
          {courseId : idcourse}).then(function(response2) 
        {                            
         });

Siempre arroja el mismo error.


Solution

  • Finally it funcionned with this code:

     await gapi.client.classroom.courses.courseWork.list({courseId: idcourse }).then(function(data){
        var courseWorks = data.result.courseWork;
    }
    

    The response "data" show results into "result", that it contain a array with all taks in the course with id "idcourse".

    Thanks you!