【发布时间】:2014-10-05 08:14:09
【问题描述】:
以下 Java 代码是将文件附件上传到 SharePoint 2013 列表项的示例。
String uploadquery =siteurl+ _api/web/Lists/GetByTitle('ListName')/items(1)/AttachmentFiles/add(FileName='File1.txt')";
HttpPost httppost = new HttpPost(uploadquery);
httppost.addHeader("Accept", "application/json;odata=verbose");
httppost.addHeader("X-RequestDigest", FormDigestValue);
httppost.addHeader("X-HTTP-Method", "PUT");
httppost.addHeader("If-Match", "*");
StringEntity se = new StringEntity("This is a Body");
httppost.setEntity(se);
HttpResponse response = httpClient.execute(httppost, localContext);
它使用内容创建文件。但它在响应中返回以下错误。
{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The type SP.File does not support HTTP PATCH method."}}}
是什么导致了这个问题?
在上面的代码中,我上传了简单的文本内容。但是如何将其他文件类型如excel/ppt或图像上传到共享点列表项?
【问题讨论】:
标签: java rest http sharepoint sharepoint-2013