title: SharePoint create Folder with Graph api in Powershell
body: <p>I am using below script to create a folder in my SharePoint library but I am getting error as Invalid request. I followed graph api as per documentation but couldn't find what is wrong in here. Any clue??</p>
  <pre><code>Function GET-Folder
  {
      param($clientId, $clientSecret)
      $tokenObject = GET-TOKEN -clientId $clientId -clientSecret $clientSecret
      $uploadFolderRequestHeaders = New-Object &quot;System.Collections.Generic.Dictionary[[String],[String]]&quot;
      $uploadFolderRequestHeaders.Add(&quot;Content-Type&quot;, &quot;application/json&quot;)
    
      $uploadFolderRequestHeaders.Add(&quot;Authorization&quot;, &quot;Bearer &quot;+ $tokenObject.access_token)
      $uploadFolderRequestBody = @{
  name= &quot;NewFoldew2r&quot;
  folder = {}
  } | ConvertTo-Json
      $fullname = &quot;https://graph.microsoft.com/v1.0/sites/$($SPid)/drives/$($LibId)/root/children/&quot;
      write-host &quot;test&quot;
      
      $uploadFolderResponse = Invoke-RestMethod $fullname -Method 'POST' -Headers $uploadFolderRequestHeaders -Body $uploadFolderRequestBody
      $uploadFolderResponse | ConvertTo-Json
      return $uploadFolderResponse
  }
  </code></pre>
  <p>latest Error:</p>
  <pre><code>    2020-12-09T20:00:52.4660142Z Invoke-RestMethod : {
  2020-12-09T20:00:52.4661057Z   &quot;error&quot;: {
  2020-12-09T20:00:52.4661551Z     &quot;code&quot;: &quot;invalidRequest&quot;,
  2020-12-09T20:00:52.4662315Z     &quot;message&quot;: &quot;Invalid request&quot;,
  2020-12-09T20:00:52.4662994Z     &quot;innerError&quot;: {
  2020-12-09T20:00:52.4663189Z       &quot;date&quot;: &quot;2020-12-09T20:00:52&quot;,
  2020-12-09T20:00:52.4663531Z       &quot;request-id&quot;: &quot;99c22009-9bcb-4c3b-acb7-cd697a5040a9&quot;,
  2020-12-09T20:00:52.4663926Z       &quot;client-request-id&quot;: &quot;99c22009-9bcb-4c3b-acb7-cd697a5040a9&quot;
  2020-12-09T20:00:52.4664153Z     }
  2020-12-09T20:00:52.4664541Z   }
  2020-12-09T20:00:52.4664659Z }
  2020-12-09T20:00:52.4664946Z At D:\a\r1\a\_DevOpsScripts\ReleaseNoteScripts\UploadInSharePoint.ps1:103 char:28
  2020-12-09T20:00:52.4665342Z + ... rResponse = Invoke-RestMethod $fullname -Method 'POST' -Headers $uplo ...
  2020-12-09T20:00:52.4665666Z +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2020-12-09T20:00:52.4666140Z     + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc 
  2020-12-09T20:00:52.4666515Z    eption
  2020-12-09T20:00:52.4666815Z     + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
  2020-12-09T20:00:52.6029759Z ##[error]PowerShell exited with code '1'.
  2020-12-09T20:00:52.6394118Z ##[section]Finishing: PowerShell Script
  </code></pre>