1

I am trying to figure out how to use the ExactTarget SOAP API to retrieve the number of records in a DataExtensionObject for a given DataExtensionObject key, for example:

 <ObjectType>DataExtensionObject[SampleDataExtensionKey]</ObjectType>

I don't need to retrieve all fields from the data extension (I'm already doing this), I just want to count the number of records/rows. Does anyone know how to do this?

2

You can retrieve rows count using an undocumented REST endpoint:

GET https://YOUR-HOST.rest.marketingcloudapis.com/data/v1/customobjectdata/key/<DE-KEY>/rowset?$page=1&$pagesize=1
{
  "links": {
    "self": "/v1/customobjectdata/token/100e08a6-6e2d-4e33-9e10-0bf30fc9ebc7/rowset?$page=1",
    "next": "/v1/customobjectdata/token/100e08a6-6e2d-4e33-9e10-0bf30fc9ebc7/rowset?$page=2"
  },
  "requestToken": "100e08a6-6e2d-4e33-9e10-0bf30fc9ebc7",
  "tokenExpireDateUtc": "2020-10-09T12:44:32.51",
  "customObjectId": "<DE-ID>",
  "customObjectKey": "<DE-KEY>",
  "pageSize": 1,
  "page": 1,
  "count": 636,
  "items": [
    {
      "keys": {
        "email": "foo@bar.net"
      },
      "values": {
        "client_id": "ABCDEFGHUJKLMNOPQ",
        "country": "",
        "foo": "",
        "bar": ""
      }
    }
  ]
}
1

I actually just went through this - and unfortunately, there isn't a direct way to get a record count.

However - there is a workaround

You can create a QueryActivity and create a counts data extensions using a query similar to this -

"SELECT COUNT(YOUR_DE.Email) as Count, "Emails" as DE_NAME FROM YOUR_DE"

The QueryActivity would point at your counts de with two columns count and DE_NAME. You can then hook up multiple queries in one shot and get a count of all your tables. You would then retrieve the data in the count table (after running the query) and determine the number of records.

This is in no way ideal, however it's currently the best approach I can see until we have the routes built out for it.

4
  • Why wouldn't an ampscript Rowcount() work here?
    – Jonny Shaw
    Jun 4 '14 at 19:04
  • @jonnyshaw This is with the SOAP API, not AMPscript Jun 4 '14 at 19:06
  • A year and a half past since this answer. Is there a simpler way to retrieve the row count? The biggest problem with the current approach is that the query goes into a queue and you sometimes have to wait a long time to get this simple row count..
    – Yoni Baciu
    Nov 13 '15 at 1:04
  • Yes. I realize that it sucks. No clue if they have changed it. I stopped using the product 7 months ago. Nov 13 '15 at 1:10

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.