Contacts API call returning same "added at" date for all contacts

contacts

#1

Hi, I’m using R to call the HubSpot API to get a list of all recent contacts in the last 30 days. It’s successful at doing that, however, from yesterday, all contacts in the account, created before yesterday have been given the same contacts.added.At date of 2016-11-24.

However, when I look in the HubSpot interface, this is not the case.

I’m not the only user of the account, so I don’t know what other activity there has been. Was hoping someone might have seen this before or know where to look in HubSpot to find more information that could answer this.

I don’t know if this will be useful to anybody, but here’s the code I’m using - maybe the error is in there. I also see the same added at dates when returning all contacts, not just recent contacts.

library(httr); library(jsonlite); library(dplyr)

  ## Get contacts added in last 30 days
  recent_contacts <- vector('list')
  i <- 1
  vid_offset <- NULL ## used with time offset parameter to page through lists of recent contacts
  time_offset <- NULL ## used with vid offset parameter to page through lists of recent contacts
  
  repeat {
    print(paste("Request no.", i))
    
    recent_contacts[[i]] <- GET(url = "https://api.hubapi.com/contacts/v1/lists/recently_updated/contacts/recent?",
             query = list(
               hapikey = ...,
               count = 250,
               showListMemberships = "true",
               vidOffset = vid_offset,
               timeOffset = time_offset
             )
    )
    recent_contacts[[i]] <- as.data.frame(jsonlite::fromJSON(content(recent_contacts[[i]], "text")))
    
    vid_offset  <- recent_contacts[[i]]$vid.offset[1]
    time_offset <- recent_contacts[[i]]$time.offset[1]
    
    if (recent_contacts[[i]]$has.more[1] == FALSE) { 
      break
    }
    
    i <- i + 1
    
  }
  
  ## Some columns contain lists which prevents rbind from working, so filter necessary columns first
  for(i in seq_along(recent_contacts)){
    recent_contacts[[i]] <- recent_contacts[[i]] %>%
      select(contacts.addedAt,
             contacts.vid,
             contacts.profile.url,
             contacts.portal.id,
             has.more,
             vid.offset,
             time.offset)
  }
  
  x <- do.call('rbind', recent_contacts)
  x$contacts.addedAt <- as.Date(as.POSIXct(x$contacts.addedAt / 1000, origin = "1970-01-01"))

Thanks!


#2

Hi @james-rw

Are you seeing the addedAt timestamp value as identical for all all records? Or just the same date after converting from that timestamp? Can you send me the Hub ID that you’re seeing this with?


#3

Hi @dadams, thanks for helping me out here.

The addedAt timestamp is different for each record, even ones that have all been grouped into the same date.

And the Hub ID I’m using is 402373.

Thanks!