title: Video upload stop working - Youtube API
body: <p>I use a PHP script to upload some daily videos to a Youtube channel (based on this code sample: <a href="https://developers.google.com/youtube/v3/code_samples/php#resumable_uploads" rel="nofollow noreferrer">https://developers.google.com/youtube/v3/code_samples/php#resumable_uploads</a>)</p>
  
  <p>The problem is after this loop:</p>
  
  <pre><code>// Read the media file and upload it chunk by chunk.
  $status = false;
  $handle = fopen($videoPath, "rb");
  while (!$status &amp;&amp; !feof($handle)) {
    $chunk = fread($handle, $chunkSizeBytes);
    $status = $media-&gt;nextChunk($chunk);
  }
  </code></pre>
  
  <p>Normally the $status variable has the video id ($status['id']) after the upload is complete but since mid January all the uploads failed with one of this errors:</p>
  
  <ul>
  <li>$status variable value stills as "false"</li>
  <li>Inside the catch, the Google_Service_Exception message is like "A service error occurred: Error calling PUT <a href="https://www.googleapis.com/upload/youtube/v3/videos?part=status%2Csnippet&amp;uploadType=resumable&amp;upload_id=xxx" rel="nofollow noreferrer">https://www.googleapis.com/upload/youtube/v3/videos?part=status%2Csnippet&amp;uploadType=resumable&amp;upload_id=xxx</a>: (400) Invalid request.  The number of bytes uploaded is required to be equal or greater than 262144, except for the final request (it's recommended to be the exact multiple of 262144).  The received request contained <strong>nnn</strong> bytes, which does not meet this requirement.", where <strong>nnn</strong> is less than 262144 and seems to be the last request.</li>
  </ul>
  
  <p>When I access the Youtube channel I can see the new videos with a status "Preparing upload" or stuck with a fixed percentage.</p>
  
  <p>My code has not changed for months but now I can't upload any new video.</p>
  
  <p>Anyone can please help me to know what's wrong? Thanks in advance!</p>