我正在关注Graph API从 Sharepoint 下载文件。
我试过这个端点: https ://graph.microsoft.com/v1.0/drives/{drive_id}/root:/{folder}/{file_name}:/content
并InputStream
使用restTemplate
:
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
httpHeaders.set(GraphConstant.AUTHORIZATION, TOKEN);
HttpEntity httpEntity = new HttpEntity(httpHeaders);
String downloadEndPoint = DOWNLOAD_FILE_ENDPOINT.replace(GraphConstant.DRIVE_ID,getDriveId(id)).replace("{folder}",folder).replace(GraphConstant.FILE_NAME, URLEncoder.encode(fileName, GraphConstant.UTF_8).replace("+", "%20"));
ResponseEntity<InputStream> responseEntity = restTemplate.exchange(downloadEndPoint,
HttpMethod.GET,
httpEntity,
InputStream.class);
if(responseEntity.getStatusCode().equals(HttpStatus.OK)){
return responseEntity.getBody();
}
responseEntity.getBody()
返回null
。
Graph Download file API的返回类型是什么?这里有任何输入吗?
我正在使用 SpringBoot 应用程序并使用 restTemplate 进行调用(不使用 Microsoft SDK 进行图形调用)。