我是OneDrive for Business REST服务的新手,我在root用户目录中创建文件没有任何问题。不幸的是,我正在尝试使用以下代码在共享子目录中创建一个文件:
post https://foo-my.sharepoint.com/_api/v1.0/me/files
/01PRDMT2S3RER67TKPWRELGF6PPPAUCVZT HTTP/1.1
OData-Version: 4.0;NetFx
OData-MaxVersion: 4.0;NetFx
Accept: application/json;odata.metadata=minimal
Accept-Charset: UTF-8
User-Agent: Microsoft ADO.NET Data Services
Authorization: Bearer .........
X-ClientService-ClientTag: Office 365 API Tools 1.1.0612
Host: foo-my.sharepoint.com
Content-Length: 65
Expect: 100-continue
{"@odata.type":"#Microsoft.FileServices.File","name":"demo1.txt"}
不幸的是,我继续收到以下错误:
98 {“error”:{“code”:“ - 1,Microsoft.SharePoint.Client.InvalidClientQueryException”,“message”:“参数@ odata.type在方法GetById中不存在。”}} 0
是否可以在子目录中创建文件?
答案 0 :(得分:0)
尝试使用地址之类的 https://foo-my.sharepoint.com/_api/v1.0/me/files/ {的ParentId} /儿童
同样,在您传递的数据中,指定"类型"构件:
{ name: "myfile.txt", type: "File" }