Hi,
i'm trying to change de Name for a AdGroupAd ImageAd , I get all the object, set the name and print it using getName, till here everythings is ok.
Then I prepare the operations to mutate it:
$operation = new AdOperation();
$operation->setOperand($adGroupAd->getAd());
$operation->setOperator(Operator::SET);
$operations[] = $operation;
When I call to mutate method
$adGroupAd = $adService->mutate($operations)->getValue()[0];
This is the response:
operations=1 service=AdService method=mutate responseTime=194 requestId=0005a2c95037f23a0a3780025f0d90a2 server=adwords.google.com isFault=1 faultMessage=[AdError.INVALID_AD_TYPE @ operations[0].operand.id]
How is possible if I am getting the AdGroupAd and just setting a new name?
All the code Attached:
var_dump($adGroupAd->getAd()->getName()); // ok
$adGroupAd->getAd()->setName($adGroupAd->getAd()->getName() . '.TEST'); // ok
var_dump($adGroupAd->getAd()->getName()); // ok
$operation = new AdOperation();
$operation->setOperand($adGroupAd->getAd());
$operation->setOperator(Operator::SET);
$operations[] = $operation;
var_dump($operations); // ok
$adGroupAd = $adService->mutate($operations)->getValue()[0]; // NOK...
printf(
"Ad of type '%s' with ID %d has updated name '%s'.\n",
$adGroupAd->getAd()->getType(),
$adGroupAd->getAd()->getId(),
$adGroupAd->getAd()->getName()
);