Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 谷歌硬盘:通过RESTAPI下载gsheets_Java_Rest_Google Api_Google Drive Api - Fatal编程技术网

Java 谷歌硬盘:通过RESTAPI下载gsheets

Java 谷歌硬盘:通过RESTAPI下载gsheets,java,rest,google-api,google-drive-api,Java,Rest,Google Api,Google Drive Api,我正在尝试从用户谷歌硬盘下载spreadhseets。我遇到了一个CORS问题 阅读此文: 我正在尝试在服务器端发出GET请求。我尝试使用restemplate.exchange,但我不确定我的响应应该采用什么格式。基本上完全迷路了 有没有办法让我把文件拉回到我的前端 无论我尝试何种格式,都会不断出现此错误: org.springframework.web.client.RestClientException:无法提取响应:未找到响应类型[interface java.sql.Blob]和内

我正在尝试从用户谷歌硬盘下载spreadhseets。我遇到了一个CORS问题

阅读此文:

我正在尝试在服务器端发出GET请求。我尝试使用restemplate.exchange,但我不确定我的响应应该采用什么格式。基本上完全迷路了

有没有办法让我把文件拉回到我的前端

无论我尝试何种格式,都会不断出现此错误:

org.springframework.web.client.RestClientException:无法提取响应:未找到响应类型[interface java.sql.Blob]和内容类型[application/vnd.openxmlformats of CedDocument.spreadsheetml.sheet]的合适HttpMessageConverter


非常感谢您的帮助

就CORS而言,这是我能找到的相关指南

用来做 CORS请求

对GoogleAPI的CORS请求类似于REST请求。网址 对于CORS请求,遵循以下模式:

使用将请求头添加到请求中 XMLHttpRequest.setRequestHeader

请求正文使用XMLHttpRequest.send方法发送

您可以通过在load和load上添加事件侦听器来注册回调 错误事件。有关XMLHttpRequest的信息,请访问此链接 事件

还要确保您有权下载电子表格文件 来自其他用户

https://www.googleapis.com +
  REST path + URL Params
Example: here is a REST request:

var restRequest = gapi.client.request({
  'path': 'https://people.googleapis.com/v1/people/me/connections',
  'params': {'sortOrder': 'LAST_NAME_ASCENDING'}
});
And here is the equivalent CORS request:

var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://people.googleapis.com/v1/people/me/connections?sortOrder=LAST_NAME_ASCENDING');