Coldfusion CF8和Salesforce REST API-更新记录

Coldfusion CF8和Salesforce REST API-更新记录,coldfusion,salesforce,Coldfusion,Salesforce,我正在尝试使用他们的RESTAPI和CF8与Salesforce进行集成。 我让OAuth位工作,获取数据等,但现在我正在尝试更新联系人表中的一些记录 首先,我考虑以“适当”的方式做这件事,因为他们- 使用HTTP修补程序更新记录 但是CFHTTP不支持补丁方法 然后我尝试运行一个SOQL查询: UPDATE Contact SET MailingStreet = 'Blah Blah' WHERE Id = '003A000000Zp4ObIAJ' 但现在我明白了 {“消息”:“意外标记:更

我正在尝试使用他们的RESTAPI和CF8与Salesforce进行集成。 我让OAuth位工作,获取数据等,但现在我正在尝试更新联系人表中的一些记录

首先,我考虑以“适当”的方式做这件事,因为他们-

使用HTTP修补程序更新记录

但是CFHTTP不支持补丁方法

然后我尝试运行一个SOQL查询:

UPDATE Contact SET MailingStreet = 'Blah Blah' WHERE Id = '003A000000Zp4ObIAJ'
但现在我明白了

{“消息”:“意外标记:更新”,“错误代码”:“格式错误的查询”}


有人知道怎么做吗?

如果您的客户端支持,您可以创建自己的补丁方法,但有一种更简单的方法。从:

如果您使用的HTTP库不允许重写或设置 任意HTTP方法名,可以发送POST请求并提供 通过查询字符串参数重写HTTP方法 _HttpMethod。在修补程序示例中,可以替换PostMethod行 对于不使用覆盖的:


在CF9 CFScript中,使用Paddyslacker已经建议的方法向URL添加_HttpMethod=PATCH:

private boolean function patchObject(required string sfid, required string type, required struct obj) {
    local.url = variables.salesforceInstance & '/services/data/v' & variables.apiVersion &'/sobjects/' & arguments.type & '/' & arguments.sfid &'?_HttpMethod=PATCH';
    local.http = new Http(url=local.url,method='post');
    //... convert obj to a json string, add to local.http ...
    local.httpSendResult = local.http.send().getPrefix();
}

我们有一个我们编写的CF9 CFC,它封装了我们将很快公开采购的其余大部分API。我会回来链接到它。

嗨,丹,你们有没有开源过你们的CFC?不是全部,但我们有一个精简版的要点:
private boolean function patchObject(required string sfid, required string type, required struct obj) {
    local.url = variables.salesforceInstance & '/services/data/v' & variables.apiVersion &'/sobjects/' & arguments.type & '/' & arguments.sfid &'?_HttpMethod=PATCH';
    local.http = new Http(url=local.url,method='post');
    //... convert obj to a json string, add to local.http ...
    local.httpSendResult = local.http.send().getPrefix();
}