title: Javascript Google Classroom API
body: <p>I'm trying to access the Google Classroom API with Javascript and am running into a syntax problem when trying to create a student.</p>
  
  <p>The relevant code is</p>
  
  <pre><code>  function createStudent () {
       var course_id = '146694xxx'
       var enrollment_code = '7ytxxx'
       var student = {
          userId: 'xxx@gmail.com'
      }
      student = gapi.client.classroom.courses.students.create({courseId:course_id,enrollmentCode:enrollment_code, params: student}).execute();
  }
  </code></pre>
  
  <p>The problem is with the named parameter for the student object. It is where I have "params". I have tried every name I can think of like requestBody, body and a million others. The error I get is</p>
  
  <pre><code>{
    "error": {
      "code": 400,
      "message": "Invalid JSON payload received. Unknown name \"params\" at 'student': Cannot find field.",
      "status": "INVALID_ARGUMENT",
      "details": [
        {
          "@type": "type.googleapis.com/google.rpc.BadRequest",
          "fieldViolations": [
            {
              "field": "student",
              "description": "Invalid JSON payload received. Unknown name \"params\" at 'student': Cannot find field."
            }
          ]
        }
      ]
    }
  }
  </code></pre>
  
  <p>How should I be representing that request body object in the call?</p>
  
  <p>Thanks.</p>
  
  <p>Harry</p>