title: Google Drive REST API - Invalid permission value for only one user
body: <p>I implemented Google Drive file permissions into my application. Everything works perfectly, only for one user (email), when I try to <a href="https://developers.google.com/drive/v2/reference/permissions" rel="nofollow noreferrer">insert a permission</a>, I get </p>
  
  <blockquote>
    <p>bad request (400): Invalid permission value </p>
  </blockquote>
  
  <p>Anyone has an idea why would I get this error just for one user? I don't see any restrictions for this user, but maybe I missed something.</p>
  
  <p>Here is my insert permission function (I am using <a href="https://github.com/google/google-api-php-client" rel="nofollow noreferrer">google api client</a> (REST API v2)):</p>
  
  <pre><code>public function insert_permission($FileID, $Value, $Type, $Role, $OptParams = array(), $Service = NULL) {
      if(empty($Service)) {
         $Client = $this-&gt;get_client_sa();
         $Service = new Google_Service_Drive($Client);
      }
  
      $NewPermission = new Google_Service_Drive_Permission();
      $NewPermission-&gt;setValue($Value);
      //$NewPermission-&gt;setEmailAddress($Value);
      $NewPermission-&gt;setType($Type);
     // commenter additional role
     if($Role == "commenter") {
         $Role = "reader";
         $NewPermission-&gt;setAdditionalRoles(["commenter"]);
     }
      $NewPermission-&gt;setRole($Role);
  
      $i = 0;
      $maxTries = 3;
      $ErrorMessage = "";
      while($i &lt; $maxTries) {
          try {
              return $Service-&gt;permissions-&gt;insert($FileID, $NewPermission, $OptParams);
          } catch (Exception $E) {
              $ErrorMessage = $E-&gt;getMessage();
              if($E-&gt;getCode() != 500)
                  $i++;
          }
      }
  
      $this-&gt;session-&gt;set_userdata("error", $ErrorMessage);
      return $E;
  }
  </code></pre>
  
  <p>While I was debugging I created <code>var_dump($httpRequest);</code> before calling <code>$this-&gt;client-&gt;execute($httpRequest)</code>, and I got this object (I deleted user email, file id and authorization token from the object for security and privacy reasons):</p>
  
  <pre><code>object(Google_Http_Request)#69 (15) {
    ["batchHeaders":"Google_Http_Request":private]=&gt;
    array(3) {
      ["Content-Type"]=&gt;
      string(16) "application/http"
      ["Content-Transfer-Encoding"]=&gt;
      string(6) "binary"
      ["MIME-Version"]=&gt;
      string(3) "1.0"
    }
    ["queryParams":protected]=&gt;
    array(0) {
    }
    ["requestMethod":protected]=&gt;
    string(4) "POST"
    ["requestHeaders":protected]=&gt;
    array(2) {
      ["content-type"]=&gt;
      string(31) "application/json; charset=UTF-8"
      ["authorization"]=&gt;
      string(183) "token_string"
    }
    ["baseComponent":protected]=&gt;
    string(26) "https://www.googleapis.com"
    ["path":protected]=&gt;
    string(72) "/drive/v2/files/file_id/permissions"
    ["postBody":protected]=&gt;
    string(64) "{"role":"writer","type":"user","value":"user_email"}"
    ["userAgent":protected]=&gt;
    NULL
    ["canGzip":protected]=&gt;
    NULL
    ["responseHttpCode":protected]=&gt;
    NULL
    ["responseHeaders":protected]=&gt;
    NULL
    ["responseBody":protected]=&gt;
    NULL
    ["expectedClass":protected]=&gt;
    string(31) "Google_Service_Drive_Permission"
    ["expectedRaw":protected]=&gt;
    bool(false)
    ["accessKey"]=&gt;
    NULL
  }
  </code></pre>
  
  <p>Everything looks OK to me and as I already said it works for all other users. I tested this call with Postman for the same user that is giving me problems and it worked, so there should be something wrong with my code.</p>