Hi,

is it possible to add a youtube channel to the exclueded placements on 
campaign level?

I tried with this code and php api, but received an error. 

My code is adopted to an example 
from https://developers.google.com/adwords/api/docs/samples/php/targeting

function addnegativeplacement($adWordsServices, $session, 
$campaignId,$channelid) {

    $campaignCriterionService = $adWordsServices->get($session, 
CampaignCriterionService::class);


    $campaignCriteria = [];
    $operations = [];
    foreach ($campaignCriteria as $campaignCriterion) {
      $operation = new CampaignCriterionOperation($session);
      $operation->setOperator(Operator::ADD);
      $operation->setOperand($campaignCriterion);
      $operations[] = $operation;
    }


    // Add a negative campaign criterion.
    $negativePlacement = new YouTubeChannel($session);
    $negativePlacement->setchannelId("$channelid");
    
//$negativePlacement->setCriterionType(PlacementMatchType::YOUTUBE_CHANNEL);
    $negativeCriterion = new NegativeCampaignCriterion();
    $negativeCriterion->setCampaignId($campaignId);
    $negativeCriterion->setCriterion($negativePlacement);


    $operation = new CampaignCriterionOperation();
    $operation->setOperator(Operator::ADD);
    $operation->setOperand($negativeCriterion);
    $operations[] = $operation;


    $result = $campaignCriterionService->mutate($operations);


    // Print out some information about added campaign criteria.
    foreach ($result->getValue() as $campaignCriterion) {
      printf(
          "%s with ID %d and type '%s' was added as negative placement.\n",
          $placementdomain,
          $campaignCriterion->getCriterion()->getId(),
          $campaignCriterion->getCriterion()->getType());
    }
}

 addnegativeplacement(new 
AdWordsServices(),$session,$campaignId,$channelid);


I receive the following error:

PHP Fatal error:  Uncaught exception 
'Google\AdsApi\AdWords\v201809\cm\ApiException' with message 
'[OperationAccessDenied.MUTATE_ACTION_NOT_PERMITTED_FOR_CLIENT @ 
operations[0]]'

Can you help me with this please?

Best,
Robert

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/8d02c567-eceb-4359-a68a-2d6f5ce25a2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • Add You... Robert
    • RE... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
      • ... Robert
        • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
      • ... Robert
    • Re... Robert

Reply via email to