小编Ela*_*zzi的帖子

使用 Google Apps 脚本发送 POST 请求

我正在尝试使用 Google Apps 脚本发送 POST 请求。\n根据文档,该请求由三部分组成:

\n
    \n
  1. 网址
  2. \n
  3. 标头
  4. \n
  5. 数据
  6. \n
\n

UrlFetchApp.fetch只允许2个参数。

\n

我尝试以完全不同的方式实现它。

\n

目前,我的代码如下所示:

\n
function qwe(){\n  \nconst url = 'https://api-seller.ozon.ru/v1/product/info/prices';\nconst data = {\n  "page": 1,\n  "page_size": 100};\n\nconst response = UrlFetchApp.fetch(url, { \n    body: JSON.stringify(data), // \xd0\xb4\xd0\xb0\xd0\xbd\xd0\xbd\xd1\x8b\xd0\xb5 \xd0\xbc\xd0\xbe\xd0\xb3\xd1\x83\xd1\x82 \xd0\xb1\xd1\x8b\xd1\x82\xd1\x8c '\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xbe\xd0\xb9' \xd0\xb8\xd0\xbb\xd0\xb8 {\xd0\xbe\xd0\xb1\xd1\x8a\xd0\xb5\xd0\xba\xd1\x82\xd0\xbe\xd0\xbc}!\n    headers: {\n      "Host": "api-seller.ozon.ru", \n      "Client-Id": "28000",\n      "Api-Key": "65db5b96-cbb6-4b68-8f33-c8c000000000000",\n      "Content-Type": "application/json"\n    }\n  });\n  const json = response.json();\n  console.log('Done:', JSON.stringify(json));\n}\n
Run Code Online (Sandbox Code Playgroud)\n

我收到错误"Exception: request failed for https://api-seller.ozon.ru returned code 405"\n请告诉我如何做到这一点? …

google-sheets google-apps-script

5
推荐指数
1
解决办法
6425
查看次数

标签 统计

google-apps-script ×1

google-sheets ×1