无法使用谷歌表 api 从谷歌表中获取数据

时间:2021-03-24 10:10:39

标签: node.js reactjs google-sheets google-sheets-api

我想从 google sheet api 获取数据,但它响应:

{
    "error": {
        "code": 404,
        "message": "Requested entity was not found.",
        "status": "NOT_FOUND"
    }
}

其他通过 google sheet api 创建并保存在驱动器中的文件是可读的,但是当我在驱动器中手动创建文件并尝试读取数据时,它会失败。

我使用的代码是这样的:

readfromURL = async (connectionObj, sheetId) => {
     const { accessToken } = connectionObj;
     const response = await axios(`https://sheets.googleapis.com/v4/spreadsheets/${sheetId}/values/Sheet1!A1:D5`, {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
        Accept: 'application/json',
        Authorization: `Bearer ${accessToken}`,
      },
    });
  }
}

如果需要更多信息,请告诉。

0 个答案:

没有答案