Search code examples
google-classroom

Getting "subject" value of course by API Google Classroom


How can I get or update the "subject" value for a course in the API? I did not find any information on this in the documentation

https://developers.google.com/classroom/reference/rest/v1/courses/get?authuser=1


Solution

  • EDIT

    There is a separate subject field when you are filling out a course as R1KO pointed out.

    enter image description here

    However, as can be seen by the full response of the courses object below, there is no such field in the API.

    I have called further endpoints to see if it was buried somewhere else but I cannot find it. Looking on the Issue Tracker however, revealed this Feature Request:

    Add Subject to Course

    https://issuetracker.google.com/156289085

    So it seems like the best thing you can do at this time is to go and click on the ☆ button in that feature to let Google know that you want this feature.


    The 'subject' is the 'name' in the API

    This is the whole courses object:

    {
      "id": string,
      "name": string,
      "section": string,
      "descriptionHeading": string,
      "description": string,
      "room": string,
      "ownerId": string,
      "creationTime": string,
      "updateTime": string,
      "enrollmentCode": string,
      "courseState": enum (CourseState),
      "alternateLink": string,
      "teacherGroupEmail": string,
      "courseGroupEmail": string,
      "teacherFolder": {
        object (DriveFolder)
      },
      "courseMaterialSets": [
        {
          object (CourseMaterialSet)
        }
      ],
      "guardiansEnabled": boolean,
      "calendarId": string
    }
    

    The description of the name field is as follows:

    Name of the course. For example, "10th Grade Biology". The name is required. It must be between 1 and 750 characters and a valid UTF-8 string.

    https://developers.google.com/classroom/reference/rest/v1/courses

    You can get this with the GET request:

    https://developers.google.com/classroom/reference/rest/v1/courses/get

    To get all the fields listed above, make sure to include * as the fields parameter.

    Update with the UPDATE or PATCH:

    https://developers.google.com/classroom/reference/rest/v1/courses/update https://developers.google.com/classroom/reference/rest/v1/courses/patch