googleads / googleads-java-lib

Google Ad Manager SOAP API Client Library for Java
Apache License 2.0
226 stars 360 forks source link

How to add sitelinks to my campaign using java sdk. #184

Closed yash199649 closed 5 years ago

yash199649 commented 5 years ago

SitelinkFeedItem siteLinkBuilder = SitelinkFeedItem.newBuilder() .setLinkText(StringValue.of("TExttttt")) .setLine1(StringValue.of("line1")) .setLine2(StringValue.of("line2")) .setFinalUrls(0,StringValue.of("haha")) .build();

   CampaignExtensionSetting.Builder campaignExtensionSetting = CampaignExtensionSetting.newBuilder()
            .setCampaign(StringValue.of(campaignResourceName))
            .setExtensionType(ExtensionTypeEnum.ExtensionType.SITELINK)
            .addExtensionFeedItems().build();

// .build();? CampaignExtensionSettingOperation operations = CampaignExtensionSettingOperation.newBuilder().setCreate(campaignExtensionSetting).build();

    try (CampaignExtensionSettingServiceClient campaignExtensionServiceClient =
                 googleAdsClient.getLatestVersion().createCampaignExtensionSettingServiceClient()) {
        MutateCampaignExtensionSettingsResponse response =
                campaignExtensionServiceClient.mutateCampaignExtensionSettings(
                        Long.toString(customerId), ImmutableList.of(operations));
        logger.info("Added sitelinks to the given/campaign criteria");
nwbirnie commented 5 years ago

Hey, your code is using the google-ads-java library, which is for the beta Google Ads API. This is the issue tracker for the AdWords API library.

The code looks reasonable, I don't see anything obivously wrong. Do you receive an error when executing this call?

yash199649 commented 5 years ago

Achieved the same using ExtensionFeedItem and CampaignExtensionSetting. Thanks!