Support add list IP to Campaign in adwords API by .NET

31 views
Skip to first unread message

Huy Nguyễn Văn

unread,
Aug 9, 2016, 3:41:42 AM8/9/16
to AdWords API Forum
I have list Campaign and list IP

I want add list IP for each campaign ?

 Selector selector = new Selector() {
        fields 
= new string[] { Campaign.Fields.Id, Campaign.Fields.Name, Campaign.Fields.Status },
        ordering 
= new OrderBy[] { OrderBy.Asc(Campaign.Fields.Name) }
      
};


      
(user.Config as AdWordsAppConfig).ClientCustomerId = txtCustomerId.Text;


      
try {
        
CampaignService service =
            
(CampaignService) user.GetService(AdWordsService.v201601.CampaignService);


        
CampaignPage page = service.get(selector);


        
// Display campaigns.
        
if (page != null && page.entries != null && page.entries.Length > 0) {
          
DataTable dataTable = new DataTable();
          dataTable
.Columns.AddRange(new DataColumn[] {
              
new DataColumn("Serial No.", typeof(int)),
              
new DataColumn("Campaign Id", typeof(long)),
              
new DataColumn("Campaign Name", typeof(string)),
              
new DataColumn("Status", typeof(string))
          
});
          
for (int i = 0; i < page.entries.Length; i++) {
            
Campaign campaign = page.entries[i];
            
DataRow dataRow = dataTable.NewRow();
            dataRow
.ItemArray = new object[] {+ 1, campaign.id, campaign.name,
                campaign
.status.ToString()
            
};
            dataTable
.Rows.Add(dataRow);

             
// add list 
ipAddress Exclusions  to campaign ?


          
}

          
CampaignGrid.DataSource = dataTable;
          
CampaignGrid.DataBind();
        
} else {
          
Response.Write("No campaigns were found.");
        
}
      
} catch (Exception e) {
        
Response.Write(string.Format("Failed to get campaigns. Exception says \"{0}\"",
            e
.Message));
      
}
    
}




Please!

Joyce Lava

unread,
Aug 9, 2016, 3:50:32 AM8/9/16
to AdWords API Forum
Hello,

Apologies for the delayed response. You can use the CampaignCriterionService to add ipAddress exclusion as NegativeCampaignCriterion with criterion as IpBlock. You may refer to this example code (.NET client library) that shows how to use the NegativeCampaignCriterion. You need to replace the keyword object (highlighted line here from the example code) with the IpBlock object to be the criterion of negativeCriterion.

Hope this helps.

Best,
Joyce, AdWords API Team
Reply all
Reply to author
Forward
0 new messages