Sharepoint REST getfilebyid有时会返回 - 404 - 找不到

时间:2016-03-11 03:37:49

标签: rest sharepoint sharepoint-api

我试图通过它的唯一ID(GUID)下载该文件,并且在99%它正常工作,但在某些情况下,我发现http未找到 - 404.但我知道该文件存在,我从文档库中获取的元数据中知道它的唯一ID。 如果我手中拿着元数据,怎么找不到文件?

我正在做下一个(Java):

//itemID is taken from the library listing (using web service) as uniqueid (guid)
String requestUrl = site + "/_api/web/GetFileById('" + itemID.substring(1, itemID.lastIndexOf('}')) + "')/$value"; //Remove {} from the unique id
HttpGet request = new HttpGet(requestUrl);
// setting auth credentials to the request.
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000).build();
request.setConfig(requestConfig);
request.addHeader("accept", "application/json; odata=verbose");
HttpResponse result = httpClient.execute(request);
int iRet = result.getStatusLine().getStatusCode(); //Here iRet = 404, sometimes.

由于

1 个答案:

答案 0 :(得分:0)

根据以前的经验,我会通过并发连接寻找锁定。我看到你的代码中有60秒超时(setConnectTimeout(60000))。例如,你有没有尝试过如果一个查询返回一个有效的结果,并且在(比如120s)之后你在60s超时内尝试两次,它会返回404?