Closed rajaharsha closed 5 years ago
@rajaharsha There has been a very small change in the API. Instead of adding an element in the list named timeZoneID
it should be named timeZoneId
(with a lowercase "d" at the end). That is why the error is asking for an element named timeZoneId
and is not recognizing your timeZoneID
version.
@StevenMMortimer Thank you much for prompt response. Your answer is helpful and resolves the error.
Cheers 👍
@rajaharsha Awesome. If you need to know any other release notes, they are listed here: https://github.com/StevenMMortimer/rdfp/releases/tag/v0.1.3
We are encountering below error after we updating to latest "rdfp" version: 0.1.3
Error: Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element '{"https://www.google.com/apis/ads/publisher/v201811":timeZoneID}'. One of '{"https://www.google.com/apis/ads/publisher/v201811":timeZoneId}' is expected.
We are using the below two functions and encountering the error when we are calling the function "request_county_90day_inventory" with an input value.
Kindly help with some guidance.
`constructLineItem <- function(startDate, endDate, deliveryRateType, frequencyCaps, lineItemType, priority, costType, creativePlaceholders, primaryGoal, targeting){ final <- list() final$startDateTime$date <- list(year=as.integer(format(startDate, '%Y')), month=as.integer(format(startDate, '%m')), day=as.integer(format(startDate, '%d'))) final$startDateTime$hour=23 final$startDateTime$minute=59 final$startDateTime$second=59 final$startDateTime$timeZoneID="America/New_York"
final$endDateTime$date <- list(year=as.integer(format(endDate, '%Y')), month=as.integer(format(endDate, '%m')), day=as.integer(format(endDate, '%d'))) final$endDateTime$hour=23 final$endDateTime$minute=59 final$endDateTime$second=59 final$endDateTime$timeZoneID="America/New_York"
if(!is.null(deliveryRateType)) final$deliveryRateType <- deliveryRateType
if(is.null(frequencyCaps$maxImpressions) || is.null(frequencyCaps$numTimeUnits) || is.na(frequencyCaps$maxImpressions) || is.na(frequencyCaps$numTimeUnits)){ frequencyCaps <- NULL } if(!is.null(frequencyCaps)) final$frequencyCaps <- frequencyCaps
if(!is.null(lineItemType)) final$lineItemType <- lineItemType if(!is.null(priority)) final$priority <- priority if(!is.null(costType)) final$costType <- costType
split_size <- strsplit(creativePlaceholders, 'x') final$creativePlaceholders$size <- list(width=as.integer(split_size[[1]][1]), height=as.integer(split_size[[1]][2]), isAspectRatio='false') final$creativePlaceholders$expectedCreativeCount <- 1 final$creativePlaceholders$creativeSizeType <- 'PIXEL'
if(!is.null(primaryGoal)) final$primaryGoal <- primaryGoal if(!is.null(targeting)) final$targeting <- targeting
finalfinal <- list(lineItem=final)
return(finalfinal) }`
`request_county_90day_inventory <- function(targeted_counties){ t <- constructInventoryTargetingList(adUnitId=** criterias=list('695056'=** '695686'=** '604806'=**)) hypothetical_line_item <- constructLineItem(startDate=Sys.Date() + 1, endDate=Sys.Date() + 91, deliveryRateType='EVENLY', frequencyCaps=list(maxImpressions=NULL, numTimeUnits=NULL, timeUnit=NULL), lineItemType='STANDARD', priority=6, costType='CPM', creativePlaceholders='320x150', primaryGoal=list(goalType='LIFETIME', unitType='IMPRESSIONS', units=1000), targeting=t) request_data <- list(lineItem=hypothetical_line_item, forecastOptions=list(includeTargetingCriteriaBreakdown='true', includeContendingLineItems='false')) r <- dfp_getAvailabilityForecast(request_data, as_df = FALSE) breakdowns <- r[[1]][c(names(r[[1]]) %in% 'targetingCriteriaBreakdowns')]
drop first (ad unit) and last 1 ad size
parse all the individual matched geos
avails <- ldply(head(tail(breakdowns,-1),-1), .fun=function(x){ return(as.data.frame(x)) }, .id=NULL) avails <- avails %>% mutate(ImpressionsTotal=as.integer(matchedUnits), ImpressionsAvailable=as.integer(availableUnits), ImpressionsBooked=as.integer(ImpressionsTotal-ImpressionsAvailable)) %>% select(targetingCriteriaName, ImpressionsBooked, ImpressionsAvailable) return(avails) }`
request_county_90day_inventory(******************)