Disclaimer: I know that this question has been asked before. The answer provided in this answer worked for me in the past, but for some reason has stopped now.
I am pulling Marketing email statistics from the Mailchimp API. I have been doing this for the last half year or so. However, in the past 2 months, I believe the structure of what I pull has changed and thus, my code no longer works and I cannot figure out why. I believe it has something to do with the nested data frames within my list of data frames that I receive.
Here is an example of my code and the resulting list of data frames. I have removed sensitive information from my code and image:
opens1 <- GET("https://us4.api.mailchimp.com/3.0/reports/***ReportNumber***/sent-to?count=4000",authenticate('***My Company***', '***My-Password***'))
opens1 <- content(opens1,"text")
opens1 <- fromJSON(opens1)
opens1 <- ldply(opens1, data.frame)
Error in allocate_column(df[[var]], nrows, dfs, var) :
Data frame column 'merge_fields' not supported by rbind.fill
On a quick glance, this seems to work for me:
library(httr) campaign_id <- "-------" apikey = "------" url <- sprintf("https://us1.api.mailchimp.com/3.0/reports/%s/sent-to", campaign_id) opens <- GET(url, query = list(apikey = apikey, count = 4000L)) lst <- rjson::fromJSON(content(opens, "text")) df <- dplyr::bind_rows( lapply(lst$sent_to, function(x) as.data.frame(t(unlist(x)), stringsAsFactors = F) ))