0

I'm trying to access Data Extensions' Data (Rows, columns, etc...) through Node API.

const ET_Client = require('../node_modules/sfmc-fuelsdk-node');

const clientId = 'clientId'
const clientSecret = 'clientSecret'
const stack = 'S10'
const obj = {
  origin: 'https://XXXXXXXXXXXXXX.rest.marketingcloudapis.com/',
  authOrigin: 'https://XXXXXXXXXXXXXX.auth.marketingcloudapis.com/',
  soapOrigin: 'https://XXXXXXXXXXXXXX.soap.marketingcloudapis.com/',
  authOptions: { 
    authVersion: 2,
    accountId: XXXXXXXXXXXXXX
  }
}
const client = new ET_Client(clientId, clientSecret, stack, obj);
const props = [
  'Name',
  'FieldType',
  'MaxLength', 
  'DataExtension.CustomerKey',
  'IsPrimaryKey'
  ];

const filter = {
    leftOperand: 'DataExtension.CustomerKey',
    operator: 'equals',
    rightOperand: 'XXXXXXXXXXXXXX'
}

client.dataExtensionColumn({props, filter}).get((err, resp) => {
  if(err){
    console.log("\n\nerror \n\n")
    console.log(err)
  }else{
    console.log(resp)
  }
});

but I don't know for sure what props I can Send in client.dataExtensionColumn({props }). When I remove this props from the "request" (client.dataExtensionColumn({props, filter}) I get the following error:

{ error: 'A property list is required for DE column retrieval.',   documentation:    'https://code.exacttarget.com/apis-sdks/fuel-sdks/data-extension-columns/data-extension-column-retrieve.html' }

And then, when I try to access the link received, I get Internal Server Error

enter image description here

The docs are a little confusing, Where can I find the properties I can send in this (and to others Objects: DataExtension, DataExtensionRow, etc...) request?

1

Under the hood, those requests use SFMC SOAP API. You can find the corresponding properties in these docs:

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/dataextensionfield.htm

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/dataextension.htm

The properties for DataExtensionRow would just be the fields in your Data Extension.

| improve this answer | |
0

Complementing Tyler answer... I also had opened a case and the support answered the same thing Tyler did, but with and Addition:

[...] However this is not documented because FuelSDK-Node is not the functionality from Marketing cloud, It is developed by third party which makes an API call towards Marketing cloud. So all the properties of DataExtensionField and other objects may or may not be supported by FuelSDK-Node.

| improve this answer | |
0

I spend a while testing right now. I want to read a few data extensions with their columns and the package sfmc-fuelsdk-node is bad documentated.

It took a while until the filter for the data extension name worked. It wasn't possible for me to use the operator "equals". It worked only with "like". Maybe that's a help for someone else.

const ET_Client = require('sfmc-fuelsdk-node');
const client = new ET_Client('client_id', 'client_secret', 'S10', {
    origin: 'https://xxx.rest.marketingcloudapis.com/',
    authOrigin: 'https://xxx.auth.marketingcloudapis.com/',
    soapOrigin: 'https://xxx.soap.marketingcloudapis.com/',
    authOptions: {
        authVersion: 2,
        accountId: 1337 // mid
    }
});
function getColumns(dataExtension) {
    const de = client.dataExtensionColumn({
        props: [
            'Name'
        ],
        filter: {
            leftOperand: 'CustomerKey',
            operator: 'like',
            rightOperand: dataExtension.CustomerKey // customer key of the data extension
        }
    });

    return new Promise((resolve, reject) => {
        de.get((err, result) => {
            if (err) {
                return reject(err);
            }
            if (result.body.Results.length === 0) {
                return resolve([]);
            }
            const columns = [];
            result.body.Results.forEach(row => {
                columns.push(row.Name);
            });
            resolve(columns);
        });
    });
}

getColumns({
    CustomerKey: 'xxx' // customer key of data extension
}).then(data => {
    console.log(data);
}).catch(err => {
    console.log('err', err);
});
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.