エクセルからKintoneAPIを使用してレコード(サブテーブル持ち)を追加させようとしております。サブテーブルの内容だけがうまく反映されません。
Jsonはうまく出されておりJson形式チェッカーでもValidJsonと出ます。
どなたかご教授よろしくお願い致します。
★JSON作成関数コード(JsonConverterライブラリ使用)
Function MakeJson(ByVal r As Integer, ByVal c As Integer) As Object
Dim ws As Worksheet
Set ws = Sheets(“Sheet2”)
Dim ReqBody As Object
Set ReqBody = New Dictionary
ReqBody.Add “app”, 7
ReqBody.Add “record”, New Dictionary
ReqBody(“record”).Add “Manage_No”, New Dictionary
ReqBody(“record”).Add “Project_No”, New Dictionary
ReqBody(“record”)(“Manage_No”).Add “value”, ws.Range(“a2”).Value
ReqBody(“record”)(“Project_No”).Add “value”, ws.Cells(2, 2).Value
ReqBody(“record”).Add “Table”, New Dictionary
ReqBody(“record”)(“Table”).Add “value”, New Collection
Dim Count_r As Integer '2行目から取得します
Dim Table_Value As Collection
Set Table_Value = New Collection
Dim Table_Row As Object
For Count_r = 2 To r - 1
Set Table_Row = New Dictionary
Table_Row.Add “Item_No”, New Dictionary
Table_Row(“Item_No”).Add “value”, ws.Cells(Count_r, 2).Value
Table_Row.Add “Item_Name”, New Dictionary
Table_Row(“Item_Name”).Add “value”, ws.Cells(Count_r, 3).Value
Table_Row.Add “Result”, New Dictionary
Table_Row(“Result”).Add “value”, ws.Cells(Count_r, 6).Value
ReqBody(“record”)(“Table”)(“value”).Add Table_Row
Next Count_r
Set MakeJson = ReqBody
End Function
★出力JSON
{
“app”: 7,
“record”: {
“Manage_No”: {
“value”: “S-1111-2”
},
“Project_No”: {
“value”: 1
},
“Table”: {
“value”: [{
“Item_No”: {
“value”: 1
},
“Item_Name”: {
“value”: “\u571F\u58CC\u691C\u67FB\uFF13”
},
“Result”: {
“value”: “\u571F\u58CC\u9805\u76EE\uFF11”
}
},
{
“Item_No”: {
“value”: 2
},
“Item_Name”: {
“value”: “\u571F\u58CC\u691C\u67FB\uFF12”
},
“Result”: {
“value”: “4.5\u4EE5\u4E0B”
}
},
{
“Item_No”: {
“value”: 3
},
“Item_Name”: {
“value”: “\u571F\u58CC\u9805\u76EE\uFF11”
},
“Result”: {
“value”: “4.5\u4EE5\u4E0B”
}
}
]
}
}
}
★追加レコードの内容
|“Manage_No”|(SubTable) |“ProjectNo”
|“Item_No”|“Item_Name”|“Result”|
| 1 | アイテム1 |結果1 |
| 2 | アイテム2 |結果2 |
| 3 | アイテム3 |結果3 |
・
・ ←SubTableの行は読み込むエクセル行によって決まる
・