0

I'm trying to use the FuelSDK-Node to perform some CRUD operations on a Data Extension. I'm not able to find any documentation except for the Readme on the GitHub page.

I was trying to use below function from the example app to insert record to DE but it's throwing an unhandled error.

function postDERow(req, res) {
var options = {
    Name: "SDKDataExtension"
    , props: { "Key": "ThisIsTheKey", "Value": "Some random text for the value field" }
};

var deRow = ET_Client.dataExtensionRow(options);

deRow.post(function (err, response) {
    if (err) {
        res.status(500).send(err)
    } else {
        var statusCode = response && response.res && response.res.statusCode ? response.res.statusCode : 200;
        var result = response && response.body ? response.body : response;
        response && res.status(statusCode).send(result);
    }
});

};

I tried different function but it's also throwing an error

function insertRecord(req, res) {

const options = {
    Name: '3637435F-XXXX-XXXX-XXXX-9D2045A92421',
    Properties: {
        "Property": [
            { 'Name': 'id', 'Value': 'xxxxx' },
            { "Name": "emailAddress", "Value": "[email protected]" },
            { "Name": "firstName", "Value": "xxxxx" },
            { "Name": "lastName", "Value": "xxxxx" },
            { "Name": "birthdate", "Value": "12/12/2000" },
            { "Name": "phoneNumber", "Value": "1231231233" },
            { "Name": "userId", "Value": "xxxxx" }
        ]
    }
}

client.dataExtensionRow(options).post((err, resp) => {

    if (err) {
        console.log("\n\nerror \n\n")
        console.log(err)
    } else {

        console.log(resp)
        return resp;
    }
});

}

ErrorMessage: 'Unable to retrieve Data Extension using Name'

Does anyone know where I can find any documentation regarding this or can provide some examples regarding CRUD operations on DE using FuelSDK?

1 Answer 1

0

Answering my own question. Here are some examples that worked for me:

function getRecords() {

    const options = {
        Name: 'data-extension-key',
        props: [
            'id',
            'emailAddress',
            'firstName'
        ],
        filter: {
            leftOperand: 'id',
            operator: 'equals',
            rightOperand: 'filter-value'
        }
    }

    client.dataExtensionRow(options).get((err, resp) => {

        if (err) {
            console.log("\n\nerror \n\n")
            console.log(err)
        } else {

            console.log(resp)
            return resp;
        }
    });
}


function createRecord() {

    const options = {
        CustomerKey: 'data-extension-key',
        props: {
            'id': 'foobar123',
            'emailAddress': '[email protected]',
            'firstName': 'foo',
        }
    }

    client.dataExtensionRow(options).post((err, resp) => {

        if (err) {
            console.log("\n\nerror \n\n")
            console.log(err)
        } else {

            console.log(resp)
            return resp;
        }
    });
}


function updateContact() {

    const options = {
        CustomerKey: 'data-extension-key',
        props: {
            'id': 'foobar123', //primary key
            'emailAddress': '[email protected]',
            'firstName': 'foo',
        }
    }

    client.dataExtensionRow(options).patch((err, resp) => {

        if (err) {
            console.log("\n\nerror \n\n")
            console.log(err)
        } else {

            console.log(resp)
            return resp;
        }
    });
}

function deleteRecord() {

    const options = {
        CustomerKey: 'data-extension-key',
        props: {
            'id': 'foobar123', //primary key
        }
    }

    client.dataExtensionRow(options).delete((err, resp) => {

        if (err) {
            console.log("\n\nerror \n\n")
            console.log(err)
        } else {

            console.log(resp)
            return resp;
        }
    });
}

Still looking for the documentation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .