如何在 Java 中使用 Infusionsoft CRM API 添加联系人注释
How to add Notes of a contact with Infusionsoft CRM API in Java
在Infusionsoft CRM中,有一个名为“备注”的联系人字段,用于为联系人添加备注。我能够使用 xml-rpc 协议 Java 创建联系人、搜索或更新。我尝试通过以下方式添加注释(我的代码在下面)但是不能。
如何使用 Java 中的 api 为联系人添加备注?
我的做法:
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
XmlRpcClient client = new XmlRpcClient();
config.setServerURL(new URL(uri)); //my app uri
client.setConfig(config);
List params=new ArrayList();
List customField=new ArrayList();
customField.add("this is new text1\n");
customField.add("this is text2\n");
customField.add("text3\n");
customField.add("text4\n");
params.add(api_key);
params.add("ContactNotes");//found from contact Table-schema
params.add(customField);
params.add(contactId); //suppose that was an known contactId Integer.
Integer responseCode=(Integer) client.execute("ContactService.add", params);
执行代码,报错:
org.apache.xmlrpc.XmlRpcException: No method matching arguments: java.lang.String, java.lang.String, [Ljava.lang.Object;, java.lang.Integer
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
at infusionsoft.ContactOperation.addNote(ContactOperation.java:123)
at infusionsoft.Main.main(Main.java:80)
我刚刚从@Nicholas_Trecina制作的infusionsoft community post中了解到,添加了CompletionDate字段并对我的代码做了一些修改。并且有效。
编辑版本:
List params = new ArrayList();
Map noteData = new HashMap();
noteData.put("ContactId", contactId);
noteData.put("ActionDescription", "My Note Title");
noteData.put("isAppointment", 0);
noteData.put("ActionDate","20170803T08:00:00");
noteData.put("CompletionDate","20171109");
noteData.put("CreationNotes", "Note data- what i want to save as note: bla bla bla..");
params.add(api_key);
params.add("ContactAction");
params.add(noteData);
Integer responseCode = (Integer) client.execute(
"DataService.add", params);
在Infusionsoft CRM中,有一个名为“备注”的联系人字段,用于为联系人添加备注。我能够使用 xml-rpc 协议 Java 创建联系人、搜索或更新。我尝试通过以下方式添加注释(我的代码在下面)但是不能。
如何使用 Java 中的 api 为联系人添加备注?
我的做法:
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
XmlRpcClient client = new XmlRpcClient();
config.setServerURL(new URL(uri)); //my app uri
client.setConfig(config);
List params=new ArrayList();
List customField=new ArrayList();
customField.add("this is new text1\n");
customField.add("this is text2\n");
customField.add("text3\n");
customField.add("text4\n");
params.add(api_key);
params.add("ContactNotes");//found from contact Table-schema
params.add(customField);
params.add(contactId); //suppose that was an known contactId Integer.
Integer responseCode=(Integer) client.execute("ContactService.add", params);
执行代码,报错:
org.apache.xmlrpc.XmlRpcException: No method matching arguments: java.lang.String, java.lang.String, [Ljava.lang.Object;, java.lang.Integer
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
at infusionsoft.ContactOperation.addNote(ContactOperation.java:123)
at infusionsoft.Main.main(Main.java:80)
我刚刚从@Nicholas_Trecina制作的infusionsoft community post中了解到,添加了CompletionDate字段并对我的代码做了一些修改。并且有效。
编辑版本:
List params = new ArrayList();
Map noteData = new HashMap();
noteData.put("ContactId", contactId);
noteData.put("ActionDescription", "My Note Title");
noteData.put("isAppointment", 0);
noteData.put("ActionDate","20170803T08:00:00");
noteData.put("CompletionDate","20171109");
noteData.put("CreationNotes", "Note data- what i want to save as note: bla bla bla..");
params.add(api_key);
params.add("ContactAction");
params.add(noteData);
Integer responseCode = (Integer) client.execute(
"DataService.add", params);