AppScript -AppSheet API帖子问题

发布于 2025-01-24 21:58:54 字数 2466 浏览 1 评论 0原文

我正在尝试使用他们的提供了API 。我在应用程序脚本中设置了所有这些设置,并且我将获得代码200(成功),但它没有将数据添加到电子表格中。我做错了吗?

function testingAPI(){
  let appId = APP ID HERE
  var url = `https://api.appsheet.com/api/v2/apps/${appId}/tables/opportunity/Action`;
  var options = {
      "method": "post",
      "headers": {
          "applicationAccessKey": ACCESS KEY HERE
      },
      "httpBody": {
  "Action": "Add",
  "Properties": {
    "Locale": "en-US",
    "Location": "47.623098, -122.330184",
    "Timezone": "Pacific Standard Time",
    "UserSettings": {
      "Option 1": "value1",
      "Option 2": "value2"
    }
  },
  "Rows": [
    {
      "IntentionSetID": "1H3t8Dt",
      "AgentID": "11234",
      "ActivityID": 12,
      "taskComplete": true,
      "taskVerified": false,
      "task_verified_by": "",
      "proof": "https://drive.google.com/open?id=1CpzebeLtAljqHTsFHvVCCDFc-A6aXC3O",
      "agent_expected_part_detail": "",
      "poc_expected_part_detail": '',
      "assigned_point_value": '',
      "points_assigned_by": "10/31/2014",
      "actual_part_detail": "8:15:25",
      "verification_date": "18:30:33"
    }
  ]
} 
  };
  var response = UrlFetchApp.fetch(url, options);
  console.log(response.getResponseCode())
}

我能够发现API呼叫确实正在通过,但是它说“动作”缺少:

 {
  "RestAPIVersion": 2,
  "TableName": "opportunity",
  "AppTemplateVersion": "1.000247",
  "Errors": "'Action' is missing.",
  "AppTemplateName": "e280cf5a-e2de-4d24-89d3-95d384a2c044",
  "Operation": "REST API invoke",
  "RecordType": "Stop",
  "Result": "Success",
  "ResultSuccess": true,
  "StatusCode": "OK"
}

将HTTPBody更改为有效负载使我更进一步,所以现在它已经认识到“添加”方面,但是它仍然不了解正确的属性。它显示了一堆逃生角色。

REST API:
{
  "Action": "Add",
  "Properties": {},
  "Rows": []
}

Properties:
 {
  "RestAPIVersion": 2,
  "TableName": "opportunity",
  "AppTemplateVersion": "1.000250",
  "Action": "Add",
  "Errors": "API 'Properties' does not have unexpected Type of 'JObject'. Value is: '{\r\n  \"Action\": \"Add\",\r\n  \"Properties\": \"{Timezone=Pacific Standard Time, Location=47.623098, -122.330184, Locale=en-US}\",\r\n  \"Rows\": \"[Ljava.lang.Object;@489763c2\"\r\n}'",
  "AppTemplateName": "e280cf5a-e2de-4d24-89d3-95d384a2c044",
  "Operation": "REST API invoke",
  "RecordType": "Start",
  "Result": "Failure"
}

I'm attempting to send a row to an appsheet app with their provided API. I have it all set up in app script and I'm getting a code 200 (success) but it's not adding the data to the spreadsheet. Am I doing something wrong?

function testingAPI(){
  let appId = APP ID HERE
  var url = `https://api.appsheet.com/api/v2/apps/${appId}/tables/opportunity/Action`;
  var options = {
      "method": "post",
      "headers": {
          "applicationAccessKey": ACCESS KEY HERE
      },
      "httpBody": {
  "Action": "Add",
  "Properties": {
    "Locale": "en-US",
    "Location": "47.623098, -122.330184",
    "Timezone": "Pacific Standard Time",
    "UserSettings": {
      "Option 1": "value1",
      "Option 2": "value2"
    }
  },
  "Rows": [
    {
      "IntentionSetID": "1H3t8Dt",
      "AgentID": "11234",
      "ActivityID": 12,
      "taskComplete": true,
      "taskVerified": false,
      "task_verified_by": "",
      "proof": "https://drive.google.com/open?id=1CpzebeLtAljqHTsFHvVCCDFc-A6aXC3O",
      "agent_expected_part_detail": "",
      "poc_expected_part_detail": '',
      "assigned_point_value": '',
      "points_assigned_by": "10/31/2014",
      "actual_part_detail": "8:15:25",
      "verification_date": "18:30:33"
    }
  ]
} 
  };
  var response = UrlFetchApp.fetch(url, options);
  console.log(response.getResponseCode())
}

I was able to find that the API call is indeed going through, but it's saying the "Action" is missing:

 {
  "RestAPIVersion": 2,
  "TableName": "opportunity",
  "AppTemplateVersion": "1.000247",
  "Errors": "'Action' is missing.",
  "AppTemplateName": "e280cf5a-e2de-4d24-89d3-95d384a2c044",
  "Operation": "REST API invoke",
  "RecordType": "Stop",
  "Result": "Success",
  "ResultSuccess": true,
  "StatusCode": "OK"
}

changing httpBody to payload got me a step further, so now it's recognizing the "add" aspect, but it's still not understanding the properties correctly. it's showing a bunch of escape characters.

REST API:
{
  "Action": "Add",
  "Properties": {},
  "Rows": []
}

Properties:
 {
  "RestAPIVersion": 2,
  "TableName": "opportunity",
  "AppTemplateVersion": "1.000250",
  "Action": "Add",
  "Errors": "API 'Properties' does not have unexpected Type of 'JObject'. Value is: '{\r\n  \"Action\": \"Add\",\r\n  \"Properties\": \"{Timezone=Pacific Standard Time, Location=47.623098, -122.330184, Locale=en-US}\",\r\n  \"Rows\": \"[Ljava.lang.Object;@489763c2\"\r\n}'",
  "AppTemplateName": "e280cf5a-e2de-4d24-89d3-95d384a2c044",
  "Operation": "REST API invoke",
  "RecordType": "Start",
  "Result": "Failure"
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠我空喜 2025-01-31 21:58:54

AppSheets API 发布https://api.appsheet.com/api/v2/apps/ {appid}/tables/{tablename}/action可以用于调用操作。这意味着该操作应在AppSheet中创建,然后才能调用。

资源

The AppSheets API POST https://api.appsheet.com/api/v2/apps/{appId}/tables/{tableName}/Action can be used to invoke an action. This means that the action should be created in AppSheet before it can be called.

Resources

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文