Problems in searchInventory() if Inventory Search Service

Bijit Gupta13 Jul 2011 4:12 AM
I have a situation here. I need to call searchInventory() method of InventorySearchService of Yahoo APT API. For that I have created Placement object as follows.
Placement pc = new Placement();

pc.accountID = "12234566789";

pc.adAttributes = new AdAttributes();
pc.adAttributes.adSizeIDs = new long?[] { attributeMap[TargetingAttributeType.AdSize][0].ID };
pc.adAttributes.adFormatID = attributeMap[TargetingAttributeType.AdFormat][0].ID;
pc.adAttributes.adFormatIDSpecified = true;

pc.adOptimization = true;

pc.contentTargetingAttributes = new ContentTargetingAttributes();
pc.contentTargetingAttributes.placementTarget = new PlacementTarget();
pc.contentTargetingAttributes.placementTarget.ID = "12234566789";
pc.contentTargetingAttributes.placementTarget.type = PlacementTargetType.SelfManagedPublisher;
pc.contentTargetingAttributes.placementTarget.typeSpecified = true;

pc.name = "Test Profile for Search";
pc.startDate = DateTime.Today;
pc.startDateSpecified = true;
pc.endDate = DateTime.Today.AddDays(30);
pc.endDateSpecified = true;

pc.guaranteedPriceSettings = new PlacementGuaranteedPriceSettings();
pc.guaranteedPriceSettings.deliveryModel = DeliveryModel.Impressions;
pc.guaranteedPriceSettings.deliveryModelSpecified = true;
pc.guaranteedPriceSettings.pricingType = PricingType.CPM;
pc.guaranteedPriceSettings.pricingTypeSpecified = true;
pc.guaranteedPriceSettings.revenueModel = RevenueModel.MakeGood;
pc.guaranteedPriceSettings.revenueModelSpecified = true;
pc.guaranteedPriceSettings.price = 100;
pc.guaranteedPriceSettings.priceSpecified = true;

Now I have called the searchInventory() as searchInventory(pc, null, null, null, null, false)

But now I am getting the following exception An internal error has occurred.

Can anyone tell me what is the way out here?
Bijit Gupta13 Jul 2011 7:13 AM
a new findings.

the error I got is not coming from the searchInventory(). It is basically coming from the addPlacement() while creating the placement. I have created the Placement object as follows

Dictionary<TargetingAttributeType, TargetingAttributeValue[]> targettingAttributeMap = getTargettingAttributeMap(aptClient);

Placement pc = new Placement();

pc.accountID = SELF_MANAGED_PUBLISHER_ACCOUNT_ID;

pc.adAttributes = new AdAttributes();
pc.adAttributes.adSizeIDs = new long?[] { targettingAttributeMap[TargetingAttributeType.AdSize][0].ID };
pc.adAttributes.adFormatID = targettingAttributeMap[TargetingAttributeType.AdFormat][0].ID;
pc.adAttributes.adFormatIDSpecified = true;

pc.contentTargetingAttributes = new ContentTargetingAttributes();
pc.contentTargetingAttributes.placementTarget = new PlacementTarget();
pc.contentTargetingAttributes.placementTarget.ID = SELF_MANAGED_PUBLISHER_ACCOUNT_ID;
pc.contentTargetingAttributes.placementTarget.type = PlacementTargetType.SelfManagedPublisher;
pc.contentTargetingAttributes.placementTarget.typeSpecified = true;

pc.name = "Unique Name for Placement";
pc.startDate = DateTime.Today;
pc.startDateSpecified = true;
pc.endDate = DateTime.Today.AddDays(30);
pc.endDateSpecified = true;

pc.adOptimization = true;
pc.adOptimizationSpecified = true;

pc.guaranteedPriceSettings = new PlacementGuaranteedPriceSettings();
pc.guaranteedPriceSettings.deliveryModel = DeliveryModel.Impressions;
pc.guaranteedPriceSettings.deliveryModelSpecified = true;
pc.guaranteedPriceSettings.pricingType = PricingType.CPM;
pc.guaranteedPriceSettings.pricingTypeSpecified = true;
pc.guaranteedPriceSettings.revenueModel = RevenueModel.InternalBarter;
pc.guaranteedPriceSettings.revenueModelSpecified = true;
pc.guaranteedPriceSettings.price = 100;
pc.guaranteedPriceSettings.priceSpecified = true;
pc.guaranteedPriceSettings.impressionGoal = 100;
pc.guaranteedPriceSettings.impressionGoalSpecified = true;

OrderResponse orRes = aptClient.OrderService.addOrder(new Order
{
accountID = SELF_MANAGED_PUBLISHER_ACCOUNT_ID,
isInternal = true,
isInternalSpecified = true,
name = "Unique Name for Order"
});
pc.orderID = orRes.Order.ID;
pc.orderIDSpecified = true;

PlacementResponse plcres = aptClient.PlacementService.addPlacement(pc);