日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用nodejs实现OData的batch操作在Marketing Cloud里读取contact信息

發(fā)布時間:2024/4/17 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用nodejs实现OData的batch操作在Marketing Cloud里读取contact信息 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我們先來看看Marketing Cloud系統(tǒng)里的contact信息: 一共1218374條數(shù)據(jù)。

我們用如下的nodejs代碼通過OData來獲取這些數(shù)據(jù):

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命令直接執(zhí)行這個.js文件:

得到結(jié)果:

要獲取更多Jerry的原創(chuàng)文章,請關注公眾號"汪子熙":

總結(jié)

以上是生活随笔為你收集整理的使用nodejs实现OData的batch操作在Marketing Cloud里读取contact信息的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。