使用 API 在 OneDrive 上创建文件夹

Create folder on OneDrive with API

我正在尝试通过 API 在 OneDrive 上创建新文件夹,但出现异常

Fatal error: Uncaught exception 'League\OAuth2\Client\Provider\Exception\IdentityProviderException' with message 'Must provide one of the following facets to create an item: Bundle, File, Folder, RemoteItem

这是 $a = ["name" => "Folder"];.

如果我改成这样:

$a = ["name" => "Folder", "folder" => array()];
$this->provider->post('https://graph.microsoft.com/v1.0/me/drive/root/children',$a,$_SESSION['access_token']);

然后我得到

Property folder in payload has a value that does not match schema

example page 我假设 folder 值应该是空数组。

文件夹的正确格式是 $folderParameters = ["name" => $folderName, "folder" => ["childCount" => '0']];