新来泛滥。我当前的 crm 没有与 zoho 集成,因此我必须使用 api 调用手动更新 zoho。
到目前为止,我已经使用 Deluge 获取访问令牌并使用所述访问令牌来获取包含联系信息的大型 json 文件。
贝娄我在 json 文件中添加了许多联系人中的 2 个。我需要的是获取我在回复中收到的 json 文件
如果文件存在更新它(如果它改变了)
如果文件不存在,则添加它。
文件样本:
{ "TotalCount": 6787,
"Data": [
{
"Location": {
"Id": 9545707,
"Name": "Primary"
},
"Customer": {
"Inactive": false,
"Id": 8873547,
"Name": "John Ashley"
},
"FirstName": "John",
"LastName": "Ashley",
"PhoneNumber": "",
"PhoneNumber2": "777777777",
"Email": "email",
"Title": "",
"Fax": "",
"Notes": "",
"Id": 9342900,
"Metadata": {
"CreatedBy": "email",
"CreatedOn": "2020-04-30T17:40:39",
"UpdatedOn": "2020-04-30T17:40:39",
"UpdatedBy": "email",
"Version": 1
},
"ExternalSystemId": null
},
{
"Location": {
"Id": 9545829,
"Name": "adress"
},
"Customer": {
"Inactive": false,
"Id": 8873674,
"Name": "Ename"
},
"FirstName": "fname",
"LastName": "lname",
"PhoneNumber": "",
"PhoneNumber2": "7777777",
"Email": "email",
"Title": "",
"Fax": "",
"Notes": "",
"Id": 9343021,
"Metadata": {
"CreatedBy": "email",
"CreatedOn": "2020-04-30T16:04:23",
"UpdatedOn": "2020-04-30T16:04:23",
"UpdatedBy": "email",
"Version": 1
},
"ExternalSystemId": null
},
{
"Location": {
"Id": 9546128,
"Name": "Primary"
},
"Customer": {
"Inactive": false,
"Id": 8873966,
"Name": "name"
},
"FirstName": "fname",
"LastName": "lname",
"PhoneNumber": "",
"PhoneNumber2": "7777777777",
"Email": "email",
"Title": "",
"Fax": "",
"Notes": "",
"Id": 9343319,
"Metadata": {
"CreatedBy": "email",
"CreatedOn": "2020-04-30T18:38:02",
"UpdatedOn": "2020-04-30T18:38:02",
"UpdatedBy": "email",
"Version": 1
},
"ExternalSystemId": null
}
}
]
}
到目前为止我写的代码
(此代码在第二次“插入联系人表”之后不起作用,最重要的是它不会更新它只是添加新行)
jsonVar = getUrl("https://cloud.servicebridge.com/api/v1.1/Contacts?
pageSize=500&sessionKey=" + APIKEY);
DataVar = jsonVar.getJSON("Data");
DataList = DataVar.toJSONList();
LocationList = list();
for each Locationdata in DataList {
LocationList.add(Locationdata.getJson("Location"));
}
for each Location in LocationList {
Name = Location.getJSON("Name");
Desi = Location.getJSON("Id");
insert into contact_table
[
LocationName=Name
Location_ID=Desi
Added_User=zoho.loginuser
]
}
DataList = DataVar.toJSONList();
custList = list();
for each custdata in DataList {
custList.add(custdata.getJson("Customer"));
}
info custList;
for each Customer in custList {
Name = Customer.getJSON("Name");
Desi = Customer.getJSON("Id");
insert into contact_table
[
CustomerName=Name
CustomerId=Desi
]
}