更改通知条件(应用)

betsy_yan发表于:2021年02月23日 11:40:42更新于:2022年02月18日 15:40:59

更改通知条件(应用)的设置。

此API仅将应用的更改反映到确认应用各动作的测试环境中。
如需反映到正式环境,执行本API后,需要执行将应用的设置反映到正式环境中API

URI

https://(子域名).cybozu.cn/k/v1/preview/app/notifications/general.json

来宾空间内的应用:https://(子域名).cybozu.cn/k/guest/(空间ID)/v1/preview/app/notifications/general.json

HTTP方法

PUT

必要的访问权限

应用的管理权限

请求参数

参数名称要指定的值必须说明
app数值或字符串必须指定应用的ID。
notifications数组

用于存放设置通知条件对象的数组。
如果指定了空数组,则删除通知条件的设置。

省略时,则不会更改。

添加或更新通知条件的设置时,必须为所有现有的通知条件的设置指定出它的“notifications”。 如未指定,则将删除此通知条件的设置。

notifications[].entity对象条件必须表示设置通知条件的对象。指定“notifications”参数时必须指定此参数。
notifications[].entity.type字符串条件必须设置通知条件对象的类型。指定“entity”参数时必须指定此参数。
  • USER:用户

  • GROUP:组

  • ORGANIZATION:组织

  • FIELD_ENTITY:创建人 / 更新人 / 执行者 / 选择用户 / 选择组织 / 选择组字段

notifications[].entity.code字符串条件必须

设置通知条件对象的字段代码。指定“entity”参数时必须指定此参数。
“notifications[].entity.type”参数中指定“FIELD_ENTITY”时,请指定字段代码。

如果是来宾用户,在用户名前加上“guest/”。
notifications[].includeSubs布尔值或字符串
是否将设置继承给其下属组织。
  • 继承:true

  • 不继承(初始值):false

仅当 notifications[].entity.type 在 ORGANIZATION 或 FIELD_ENTITY 中指定了选择组织字段时才有效。
省略时为false。

notifications[].recordAdded布尔值或字符串
指定是否通过添加记录进行通知。
  • 添加记录时通知:true

  • 添加记录时不通知(初始值):false

省略时为false。

notifications[].recordEdited布尔值或字符串
指定是否通过编辑记录进行通知。
  • 编辑记录时通知:true

  • 编辑记录时不通知(初始值):false

省略时为false。

notifications[].commentAdded布尔值或字符串
指定是否通过填写回复进行通知。
  • 填写回复时通知:true

  • 填写回复时不通知(初始值):false

省略时为false。

notifications[].statusChanged布尔值或字符串
指定是否通过状态的更新进行通知。
  • 更新状态时通知:true

  • 更新状态时不通知(初始值):false

省略时为false。

notifications[].fileImported布尔值或字符串
指定是否通过文件导入进行通知。
  • 文件导入时通知:true

  • 文件导入时不通知(初始值):false

省略时为false。

notifyToCommenter布尔值或字符串
指定将回复填写到记录时是否会通知填写回复的用户。
  • 填写回复时收到通知:true

  • 填写回复时不会收到通知(初始值):false

省略时,则不会更改。

revision数值或字符串

指定更改应用设定前的修订号。 如指定的修订版本不是最新时,则请求失败。
如省略或指定为"-1"时,则不检查修订。

请求的范例

头部

PUT /k/v1/preview/app/notifications/general.json HTTP/1.1
Host: example.cybozu.cn:443
X-Cybozu-Authorization: QWRtaW5pc3RyYXRvcjpjeWJvenU=
Authorization: Basic QWRtaW5pc3RyYXRvcjpjeWJvenU=
Content-Type: application/json


正文

{
  "app": "1",
  "notifications": [
    {
      "entity": {
        "type": "USER",
        "code": "user1"
      },
      "includeSubs": false,
      "recordAdded": true,
      "recordEdited": true,
      "commentAdded": false,
      "statusChanged": false,
      "fileImported": true
    }
  ],
  "notifyToCommenter": true,
  "revision": "2"
}


应答参数

参数名称值的类型说明
revision字符串更改应用设定后的修订版号。

应答的范例

{
  "revision": "2"
}


JavaScript范例

使用API请求发送 kintone REST API 请求

var body = {
  'app': kintone.app.getId(),
  'notifications': [{
    'entity': {
      'type': 'USER',
      'code': 'user1'
    },
    'includeSubs': false,
    'recordAdded': true,
    'recordEdited': true,
    'commentAdded': false,
    'statusChanged': false,
    'fileImported': true
  }],
  'notifyToCommenter': true,
  'revision': '2'
};
kintone.api(kintone.api.url('/k/v1/preview/app/notifications/general', true), 'PUT', body, function(resp) {
  // success
  console.log(resp);
}, function(error) {
  // error
  console.log(error);
});


使用 XMLHttpRequest 请求

var body = {
  'app': kintone.app.getId(),
  'notifications': [{
    'entity': {
      'type': 'USER',
      'code': 'user1'
    },
    'includeSubs': false,
    'recordAdded': true,
    'recordEdited': true,
    'commentAdded': false,
    'statusChanged': false,
    'fileImported': true
  }],
  'notifyToCommenter': true,
  'revision': '2',
  // CSRF TOKEN: 在kintone上执行API(POST,PUT,DELETE)时必须设置
  '__REQUEST_TOKEN__': kintone.getRequestToken()
};
var url = 'https://{subdomain}.cybozu.cn/k/v1/preview/app/notifications/general.json';
var xhr = new XMLHttpRequest();
xhr.open('PUT', url);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
  if (xhr.status === 200) {
    // success
    console.log(JSON.parse(xhr.responseText));
  } else {
    // error
    console.log(JSON.parse(xhr.responseText));
  }
};
xhr.send(JSON.stringify(body));