11

The REST API documentation doesn't have any method to read from a data extension while it has a couple of writing into it.

So is SOAP is the only API to read from a DE?

2 Answers 2

26

It's not documented save for a call to GET https://www.exacttargetapis.com/data/v1/rest, but GET https://www.exacttargetapis.com/data/v1/customobjectdata/key/[DE CustomerKey]/rowset/ will do exactly what you want, and it's not limited to data extensions linked to the contact model.

I've also found it will accept at least the same query string parameters as the ContentBuilder simple asset query plus $top. You can build more complex filters with AND, OR, and parentheses. Property IS [NOT] NULL works too.

12
  • 1
    I don't know how you found this but it is brilliant - thank you! Aug 15, 2018 at 22:24
  • This is very nice solution. I just wanted to check if we can search by a particular value?Currently, this gives me all the records. In future, if records are more than 2,000 then I think it will be very time consuming.
    – user36778
    Dec 7, 2018 at 18:26
  • 1
    There are loads of undocumented api routes you can find with a call to GET https://www.exacttargetapis.com/<module>/v1/rest. They're poorly (not) documented, and I wouldn't rely on them for mission critical stuff, but they've proven exceptionally useful in specific situations. For instance, I once had a broken ContactBuilder relationship that was causing the web interface to hang; I resolved it by modifying the contact model with an undocumented route. Obviously, it'll give you more power than SFMC intended, so be careful with how you use it. Dec 7, 2018 at 23:24
  • 1
    WORKED, thanks @ClaytonVonDras!!!: ?$filter=emailaddress%20eq%20"joe%40somewhere.com" May 3, 2019 at 18:32
  • 2
    Here are some examples of filters. AND and OR work even though Simple Query documentation doesn't say so. using OR: first-name%20eq%20'John'%20or%20last-name%20eq%20'Smith' , using LIKE: first-name%20like%20'Jess%' , ** using IN:** first-name%20in%20('Jesse','John')
    – ohnit
    Mar 20, 2020 at 17:21
2

Probably best bet is something like https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/fetchAttributes.htm which allows you to go through DEs with are in the contact model.

For example:

Host: https://www.exacttargetapis.com
POST /contacts/v1/attributes/search 
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN

{
    "request": {
        "attributes": [{
                "key": "MobileConnect Demographics.First Name"
            },
            {
                "key": "MobileConnect Demographics.Last Name"
            },
            {
                "key": "Retail Orders.Order Number"
            },
            {
                "key": "Retail Orders.Order Total"
            }]

    },
    "conditionSet": {
        "operator": "And",
        "conditionSets": [],
        "conditions": [{
            "attribute": {
                "key": "Retail Orders.Order Total"
            },
            "operator": "GreaterThan",
            "value": {
                "items": ["1,000.00"]
            }
        }]
    }
}
4
  • Can you cite at least some of the relevant content here if the link answers the question? Links tend to break over time, so answers are much improved if they can stand on their own even were the links to go dead.
    – Adrian Larson
    Apr 24, 2017 at 21:17
  • 1
    Good Point! Editing now :D
    – Doug
    May 20, 2017 at 16:55
  • 1
    @Doug is key used in above example is external key for DE? The link developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/… seems to be not working. Thanks
    – Chandan
    Jul 15, 2019 at 2:55
  • 1
    Hi @Chandan, this is all based on Fully Qualified Name from Contact Builder. It doesnt required External Keys at all.
    – Doug
    Jul 15, 2019 at 14:20

You must log in to answer this question.

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