Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use nodejs to read contact information in Marketing Cloud

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use nodejs to read contact information in Marketing Cloud", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use nodejs to read contact information in Marketing Cloud" bar!

Let's first take a look at the contact information in the Marketing Cloud system:

There are 1218374 pieces of data.

We use the following nodejs code to get this data through 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" + "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)

Execute the .js file directly using the node command:

The results are obtained:

Thank you for your reading, the above is the content of "how to use nodejs to read contact information in Marketing Cloud". After the study of this article, I believe you have a deeper understanding of how to use nodejs to read contact information in Marketing Cloud, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report