使用nodejs对Marketing Cloud的contact主数据进行修改操作
假设在Marketing Cloud有这样一个contact主数据:
现在需求是使用编程语言比如nodejs修改这个contact实例的高亮属性。
代码如下:
var config = require("./mcConfig");
var request = require('request');var url = config.tokenURL;console.log("user: " + config.user + " password: " + config.password);
var getTokenOptions = {url: url,method: "GET",json:true, headers: {'Authorization': 'Basic ' + new Buffer(config.user + ":" + config.password).toString('base64'),"content-type": "application/json","x-csrf-token" :"fetch"}
};function getToken() {return new Promise(function(resolve,reject){var requestC = request.defaults({jar: true});console.log("Step1: get csrf token via url: " + url );requestC(getTokenOptions,function(error,response,body){var csrfToken = response.headers['x-csrf-token'];if(!csrfToken){reject({message:"token fetch error: " + error});return;}console.log("Step1: csrf token got: " + csrfToken);resolve(csrfToken);}); });
}function updateContact(token){return new Promise(function(resolve, reject){var sPostData = "--batch_1f7d-bd35-caed" + "\n" + "Content-Type: multipart/mixed; boundary=changeset_8f9e-9a44-9f9e" + "\n" + "\n" + "--changeset_8f9e-9a44-9f9e" + "\n" + "Content-Type: application/http" + "\n" + "Content-Transfer-Encoding: binary" + "\n" + "\n" + "MERGE Consumers('02000A21209F1EE99CDF1A1FC9AA8065')?sap-client=100 HTTP/1.1" + "\n" + "Cache-Control: max-age=360" + "\n" + "sap-contextid-accept: header" + "\n" + "Accept: application/json" + "\n" + "Accept-Language: en" + "\n" + "DataServiceVersion: 2.0" + "\n" + "MaxDataServiceVersion: 2.0" + "\n" + "x-csrf-token: fQ2Pwfmf0K_LVYoKV9QYUw==" + "\n" + "Content-Type: application/json" + "\n" + //"Content-Length: 215" + "\n" + "\n" + "{\"YY1_CustomerType_ENH\":\"Jerry测试1\"}" + "\n" + "--changeset_8f9e-9a44-9f9e--" + "\n" + "\n" + "--batch_1f7d-bd35-caed--";var requestC = request.defaults({jar: true});var createOptions = {url: config.updateContactURL,method: "POST",json:false,headers: {"content-type": "multipart/mixed;boundary=batch_1f7d-bd35-caed",'x-csrf-token': token},body:sPostData};requestC(createOptions,function(error,response,data){if(error){reject(error.message);}else {debugger;console.log("Contact updated successfully");resolve(data);}});});
}getToken().then(updateContact).catch((error) =>{console.log("error: " + error.message);
});
我在nodejs代码里把需要更改的字段值赋为"Jerry测试1”:
执行之后这个属性被成功更新了:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
使用nodejs对Marketing Cloud的contact主数据进行修改操作相关推荐
- Marketing Cloud的contact主数据的odata调用方式
下图是SAP Marketing Cloud里contact主数据界面: 这个页面的数据来源是通过OData从ABAP后台读取的. odata url:https://jerry.gcdemo.hyb ...
- 使用nodejs创建Marketing Cloud的contact数据
源代码如下: var config = require("./mcConfig"); var request = require('request');var url = conf ...
- Marketing Cloud的Contact主数据创建
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
- Marketing Cloud的contact merge机制
Marketing Cloud的contact支持多种多样的数据源,如下图所示: SAP Hybris Commerce SAP ERP SAP Cloud for Customer SAP Gigy ...
- 如何使用Chrome开发者工具找到Marketing Cloud某个contact的guid
我们使用nodejs对contact进行修改时,需要指定待修改contact实例的guid. 这个guid属于technical属性,在Marketing Cloud UI上默认情况下不可见.如何找到 ...
- 使用postman创建Marketing Cloud的Contact
首先在Marketing Cloud的UI上创建一个contact: 观察Chrome开发者工具network标签页里的HTTP请求: https://jerry.gcdemo.hybris.com/ ...
- Marketing Cloud里contact批量删除的http负载
在Marketing Cloud系统里我们在contact显示的表格里,选中多条数据,可以批量删除: 点了Delete按钮后,发送到后台的HTTP请求正文如下: –batch_1e89-cb21-3c ...
- 如何让某些用户对Marketing Cloud的contact数据只能实施只读操作
打开maintain business role这个应用: 创建一个新的business role,然后添加下列这几个catalogs: SAP_CEC_BC_MKT_ADM_PC Marketing ...
- 使用postman消费Marketing Cloud的contact读取API
url:https://jerry.gcdemo.hybris.com/sap/opu/odata/sap/CUAN_CONTACT_SRV/$batch?sap-client=100 http he ...
最新文章
- 如何一小时杀入天池OCR比赛前排?
- 网络系统管理之静态路由配置
- php追加编译imagick
- 移植opencv2.4.9到itop4412开发板
- ife 零基础学院 day 2
- html中表格布局还是div布局,Table布局 VS Div+CSS布局,选哪个?
- 常用adb shell 命令
- 拳王虚拟项目公社:闲鱼怎么卖虚拟资源商品,会不会被封号?虚拟资源自动化出售
- 反卷积(转置卷积)的理解
- node + express + sockio 在线聊天室
- Android 代码重构案例
- 关于STM32定时器使用的一个注意事项(以此为前车之鉴,重要!)
- 数据库系统原理与设计(第3版)第二章课后习题
- 深入理解Java虚拟机——Java堆栈跟踪工具(jstack)
- 【开发教程6】疯壳·ARM功能手机-中断实验教程
- 斑马旅游在千帆竞发的出境游市场能否找到属于自己的道路?
- 虚拟化bug定位神器之一 【gdbcoredump】--libvirtd hang 住
- APP开发者必备,主流安卓应用商店开发者公司账号注册
- 六年软件测试感悟 从博彦到VMware
- 中国公交广告高峰论坛——天津