質問編集履歴
1
不要箇所の削除
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
A AAAAAAAA
|
test
CHANGED
@@ -1,83 +1,5 @@
|
|
1
|
+
不要のため、文言修正しました、
|
1
|
-
|
2
|
+
ご容赦ください。
|
3
|
+
不要のため、文言修正しました、
|
4
|
+
ご容赦ください。
|
2
5
|
|
3
|
-
TrelloAPIを使用して、カスタムフィールドを更新したい。
|
4
|
-
|
5
|
-
### 前提
|
6
|
-
|
7
|
-
GASでスプレッドシートからTrelloのカードにある、カスタムフィールドを更新するシステムを作っています。機能を実装中に以下のエラーメッセージが発生しました。
|
8
|
-
下記実装コードの「updateCustomFieldItemOnCard」メソッドがうまく機能せずエラーとなります。
|
9
|
-
|
10
|
-
|
11
|
-
### 発生している問題・エラーメッセージ
|
12
|
-
|
13
|
-
```
|
14
|
-
Invalid value for custom field type
|
15
|
-
```
|
16
|
-
|
17
|
-
```
|
18
|
-
400
|
19
|
-
```
|
20
|
-
|
21
|
-
### 該当のソースコード
|
22
|
-
```js
|
23
|
-
/**
|
24
|
-
* カード詳細情報の取得処理
|
25
|
-
*/
|
26
|
-
function getDetailCard(cardId) {
|
27
|
-
let url = TRELLO_API_URL + '1/cards/' + cardId + '?key=' + TRELLO_API_KEY + '&token=' + TRELLO_API_TOKEN + '&fields=name,labels&customFieldItems=true';
|
28
|
-
let result = UrlFetchApp.fetch(url, TRELLO_API_GET_PARAMS).getContentText();
|
29
|
-
|
30
|
-
return JSON.parse(result);
|
31
|
-
}
|
32
|
-
```
|
33
|
-
|
34
|
-
```js
|
35
|
-
/**
|
36
|
-
* カスタムフィールドの取得処理
|
37
|
-
*/
|
38
|
-
function getCustomField(idCustomField) {
|
39
|
-
let url = TRELLO_API_URL + '1/customFields/' + idCustomField + '?key=' + TRELLO_API_KEY + '&token=' + TRELLO_API_TOKEN;
|
40
|
-
let result = UrlFetchApp.fetch(url, TRELLO_API_GET_PARAMS).getContentText();
|
41
|
-
|
42
|
-
return JSON.parse(result);
|
43
|
-
}
|
44
|
-
```
|
45
|
-
|
46
|
-
```js
|
47
|
-
// カードの詳細情報、出力するカスタムフィールドの情報を取得する
|
48
|
-
let targetCard = getDetailCard(cardId);
|
49
|
-
let customFieldDetail;
|
50
|
-
let customFieldName;
|
51
|
-
for (const customField of targetCard['customFieldItems']) {
|
52
|
-
customFieldDetail = getCustomField(customField['idCustomField']);
|
53
|
-
customFieldName = customFieldDetail['name'];
|
54
|
-
|
55
|
-
let bodyData = {"value": {"text": "test"}};
|
56
|
-
updateCustomFieldItemOnCard(cardId, customField['idCustomField'], bodyData);
|
57
|
-
```
|
58
|
-
|
59
|
-
```js
|
60
|
-
function updateCustomFieldItemOnCard(cardId, idCustomField, bodyData) {
|
61
|
-
let param = {
|
62
|
-
'method': 'PUT',
|
63
|
-
'headers': {'ContentType': 'application/json'},
|
64
|
-
'muteHttpExceptions' : true,
|
65
|
-
'body': bodyData,
|
66
|
-
};
|
67
|
-
let url = TRELLO_API_URL + '1/cards/' + cardId + '/customField/' + idCustomField + '/item?key=' + TRELLO_API_KEY + '&token=' + TRELLO_API_TOKEN;
|
68
|
-
let result = UrlFetchApp.fetch(url, param);
|
69
|
-
|
70
|
-
return;
|
71
|
-
}
|
72
|
-
```
|
73
|
-
|
74
|
-
### 試したこと
|
75
|
-
|
76
|
-
updateCustomFieldItemOnCardメソッドの9行目の'body'のキーが異なるかと思い、
|
77
|
-
payloadなどの指定方法を変えましたが、同じエラーとなります。
|
78
|
-
|
79
|
-
公式APIドキュメントのUpdate Custom Field item on Card箇所を見ていますが、そもそもこちらの使用するAPIが違うんでしょうか。
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|