title: How to create course work for a Google Classroom project using API in php
body: <p>I want to create a course work(Assignment) as a course teacher using Google Classroom API to itself for a project in PHP. To create an assignment which correct code I wrote? Give me some suggestions with PHP code for creating an assignment.</p>
  <p>I've added some code to the quickstart.php file.</p>
  <p><strong>Code:</strong></p>
  <pre><code>$client = getClient();
          $courseId = '394192735087';
          $service = new Google_Service_Classroom($client);
          $post_body = new Google_Service_Classroom_CourseWork(array(
            'workType' =&gt; 'ASSIGNMENT',
            'title' =&gt; 'Quiz-5',
            'description' =&gt; 'where you add up by the number of numbers',
            'state' =&gt; 'PUBLISHED',
            'maxPoints' =&gt; 100,
            'associatedWithDeveloper' =&gt; true,
            'assigneeMode' =&gt; 'ALL_STUDENTS',
            'submissionModificationMode' =&gt; 'SUBMISSION_MODIFICATION_MODE_UNSPECIFIED'
            ));
  
          $service-&gt;courses_courseWork-&gt;create($courseId, $post_body);
  </code></pre>
  <p><strong>But when I run this code in quickstart.php at localhost the following problems can be seen.</strong></p>
  <pre><code>Fatal error: Uncaught Google\Service\Exception: {
    &quot;error&quot;: {
      &quot;code&quot;: 400,
      &quot;message&quot;: &quot;Invalid JSON payload received. Unknown name \&quot;name\&quot; at 'course_
  work': Cannot find field.&quot;,
      &quot;errors&quot;: [
        {
          &quot;message&quot;: &quot;Invalid JSON payload received. Unknown name \&quot;name\&quot; at 'cou
  rse_work': Cannot find field.&quot;,
          &quot;reason&quot;: &quot;invalid&quot;
        }
      ],
      &quot;status&quot;: &quot;INVALID_ARGUMENT&quot;
    }
  }
   in C:\xampp\htdocs\api\vendor\google\apiclient\src\Http\REST.php:128
  
  </code></pre>
  <p><strong>How can I solved it ?</strong></p>