Closed cjmartinIndra closed 6 years ago
@cjmartinIndra This is sort of a dumb thing about the DFP API, but the elements must be in the same order as listed in the LineItem type reference page. So your code should work if you change the order to:
sample_line <- list()
sample_line$startDateTimeType <- 'IMMEDIATELY'
sample_line$endDateTime <- date2DFPDateTimeObj(Sys.Date() + 10, daytime='end')
sample_line$creativeRotationType <- 'OPTIMIZED'
sample_line$roadblockingType<- 'AS_MANY_AS_POSSIBLE'
sample_line$primaryGoal <- list(goalType='DAILY', unitType='IMPRESSIONS', units=100)
sample_line$lineItemType <- 'SPONSORSHIP'
sample_line$costType<-'CPM'
sample_line$creativePlaceholders$size <- list(width=300, height=600, isAspectRatio='false')
sample_line$creativePlaceholders$expectedCreativeCount <- 3
sample_line$creativePlaceholders$creativeSizeType <- 'PIXEL'
device_targets<-as.list(c(30000,30001,30002,30003))
device_targets <- lapply(device_targets, FUN=function(x){list(id=x)})
names(device_targets) <- rep('targetedDeviceCategories', length(device_targets))
sample_line$targeting <- list(inventoryTargeting=list(targetedAdUnits=list(adUnitId=20378992807,
includeDescendants="true")),
technologyTargeting=list(deviceCategoryTargeting=device_targets))
Please see my code below to forecast avilability:
sample_line <- list() sample_line$startDateTimeType <- 'IMMEDIATELY' sample_line$endDateTime <- date2DFPDateTimeObj(Sys.Date() + 10, daytime='end') sample_line$lineItemType <- 'SPONSORSHIP' sample_line$costType<-'CPM' sample_line$creativePlaceholders$size <- list(width=300, height=600, isAspectRatio='false') sample_line$creativePlaceholders$expectedCreativeCount <- 3 sample_line$creativePlaceholders$creativeSizeType <- 'PIXEL' sample_line$primaryGoal <- list(goalType='DAILY', unitType='IMPRESSIONS', units=100) sample_line$creativeRotationType <- 'OPTIMIZED' sample_line$roadblockingType<- 'AS_MANY_AS_POSSIBLE' device_targets<-as.list(c(30000,30001,30002,30003)) device_targets <- lapply(device_targets, FUN=function(x){list(id=x)}) names(device_targets) <- rep('targetedDeviceCategories', length(device_targets)) sample_line$targeting <- list(inventoryTargeting=list(targetedAdUnits=list(adUnitId=20378992807, includeDescendants="true")), technologyTargeting=list(deviceCategoryTargeting=device_targets))
forecast_request <- list(lineItem=list(lineItem=sample_line), forecastOptions=list(includeTargetingCriteriaBreakdown='true', includeContendingLineItems='false')) this_result <- dfp_getAvailabilityForecast(forecast_request, as_df=FALSE)
The function _dfpgetAvailabilityForecast returns an error when using the following attributes in the lineitem type: creativeRotationType, roadblockingType
V201702 contains those attributes for the LineItem type (https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ForecastService.LineItem). Could you please help me with this?