使用nodejs实现OData的batch操作在Marketing Cloud里读取contact信息
我们先来看看Marketing Cloud系统里的contact信息: 一共1218374条数据。
我们用如下的nodejs代码通过OData来获取这些数据:
var request = require('request');
var config = require("./mcConfig");var url = config.getContactBatchURL;var sBody = "--batch_c914-a60c-1877" + "\n" +
"Content-Type: application/http" + "\n" +
"Content-Transfer-Encoding: binary" + "\n" +
"\n" +
"GET InteractionContacts?sap-client=100&$skip=0&$top=2&$select=ImageURL%2cName%2cContactLevelName%2cCountryName%2cCity%2cEMailAddress%2cPhoneNumber%2cMobilePhoneNumber%2cCorporateAccountName%2cInteractionContactUUID%2cRelationship%2cType&$inlinecount=allpages HTTP/1.1" +
"sap-cancel-on-close: true" + "\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" +
"\n" + "\n" +
"--batch_c914-a60c-1877--";var getContactOptions = {url: url,method: "POST",json:false,headers: {"content-type": "multipart/mixed;boundary=batch_c914-a60c-1877",'Authorization': 'Basic ' + new Buffer(config.user + ":" + config.password).toString('base64')},body: sBody
};function getContact() {return new Promise(function(resolve,reject){var requestC = request.defaults({jar: true});console.log("Step1: get contact via url: " + url );requestC(getContactOptions,function(error,response,body){if( error){console.log("error occurred: " + error);reject(error);}console.log("response:" + body);var nStartIndex = body.indexOf("{");var nLastIndex = body.lastIndexOf("}");if( nStartIndex < 0 || nLastIndex < 0)return;var sPayload = body.substring(nStartIndex, ++nLastIndex);resolve(JSON.parse(sPayload));}); });
}function displayResult(oResult){console.log(oResult);
}getContact().then(displayResult);
复制代码
使用node命令直接执行这个.js文件:
得到结果:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
使用nodejs实现OData的batch操作在Marketing Cloud里读取contact信息相关推荐
- 使用OData API批量删除Marketing Cloud里的contact
基本思路就是使用Odata的batch操作,在一个batch容器里放入多个delete动作.一个典型的payload如下面所示: –batch_1e89-cb21-3cdd Content-Type: ...
- 如何判断Marketing Cloud里OData服务调用成功了
例子:postman里调用Marketing Cloud contact创建的API,如果成功,会收到HTTP 201 Created的状态码,并且受到一条SAP message,code为CUAN_ ...
- Marketing Cloud里使用了哪个版本的UI5 Odata模型?
https://ui5.sap.com/1.60.6/resources/sap/ui/model/odata/ODataModel.js 要获取更多Jerry的原创文章,请关注公众号"汪子 ...
- Marketing Cloud里Odata请求响应结构的解析
代码应该怎么写呢? 从调试器里看到响应结构是一个巨大的json对象,顶层属性名为d: 然后是results属性,这是一个数组. 所以最后的代码为: function displayResult(oRe ...
- Marketing Cloud的contact主数据的odata调用方式
下图是SAP Marketing Cloud里contact主数据界面: 这个页面的数据来源是通过OData从ABAP后台读取的. odata url:https://jerry.gcdemo.hyb ...
- 一个最简单的例子学会使用nodejs redis库进行数据库操作
要学会使用Redis数据库,总的先有个可用的数据库吧.这个只有大家自己想办法了,我用的是SAP云平台上的Redis实例,很多其他的云平台比如GCP,微软的Azure和亚马逊的AWS也都有Redis服务 ...
- 使用nodejs对Marketing Cloud的contact主数据进行修改操作
假设在Marketing Cloud有这样一个contact主数据: 现在需求是使用编程语言比如nodejs修改这个contact实例的高亮属性. 代码如下: var config = require ...
- Marketing Cloud的notification的OData实现
在Marketing Cloud界面的右上角,点击这个icon可以进入notification界面: 类似SAP Netweaver的事务码ST22: 这些notification是SAP Marke ...
- 使用nodejs创建Marketing Cloud的contact数据
源代码如下: var config = require("./mcConfig"); var request = require('request');var url = conf ...
最新文章
- 人生苦短,我要换Go!
- 图灵机原理三体中人计算机,有关计算机中人列计算机的问题
- MongoDB优化之二:常见优化方法
- 使用两个队列实现一个栈
- 详解华为与三星专利之争 律师称可能会打持久战
- django-登陆功能-使用ajax实现
- 新型冠状病毒传染性有多强?何时达到峰值?来看一下数学和统计建模结果
- PVSCSI还是LSI logic?VM SCSI控制器驱动的选择
- HelloMybatis
- 持续集成:软件质量改进和风险降低之道
- visio 绘图矢量图素材网站
- HiJson修改版,修改为按json字符串默认字段顺序格式化
- arm开发板挂载win10和ubuntu haneWIN NFS Server
- Apollo学习笔记(6)module control
- 诱导系统服务器,交通诱导及信息发布系统
- 网页应该如何录屏呢?
- Android之UiAutomator测试框架源码分析(第三篇:UiDevice功能介绍)
- MindManager 2018有趣的HTML5互动演示
- 有道互动内容引擎 Ceramics 的业务实践
- 计算机无法识别新挂硬盘,电脑更新后系统不识别移动硬盘的原因分析及解决办法 系统无法识别移动硬盘教程(两种方...