ImageAd Updating Name PHP V201809

31 views
Skip to first unread message

Héctor Prieto

unread,
Apr 8, 2020, 11:46:51 AM4/8/20
to AdWords API and Google Ads API Forum
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()
);



Google Ads API Forum Advisor Prod

unread,
Apr 8, 2020, 3:19:30 PM4/8/20
to hpr...@telecoming.com, adwor...@googlegroups.com

Hi Héctor,

Thank you for reaching out. When you update the ad, you would need to create a new instance of the type of the ad and then pass in the ad id you’d like to update. Please refer to this code example on how to update an existing ad. Please let me know if you have any further questions.

Thanks and Regards,
Xiaoming, Google Ads API Team



 

ref:_00D1U1174p._5001UZWtY5:ref

Héctor Prieto

unread,
Apr 10, 2020, 2:12:23 AM4/10/20
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
Then, just for update the name I need to set all fields? Because if I create a new instance I am having an empty object.
--
 
 
 
Héctor Prieto
Software Developer
hpr...@telecoming.com  
 
 
 
 
 Telecoming - Make it digital        
5000_empresas
     
1000_empresas
 
 
Paseo de la Castellana, 95. Torre Europa, pl 16. 28046 Madrid, Spain |telecoming.com
 
 
 Este correo electrónico y sus archivos adjuntos están dirigidos únicamente a la(s) dirección(es) indicada(s) anteriormente. El carácter confidencial, personal e intransferible del mismo está protegido legalmente. Cualquier publicación, reproducción, distribución o retransmisión no autorizada, ya sea completa o en parte, se encuentra prohibida. Si ha recibido este mensaje por equivocación, notifíquelo inmediatamente a la persona que lo ha enviado y borre el mensaje original junto con sus ficheros anexos sin leerlo ni grabarlo en modo alguno.

Héctor Prieto

unread,
Apr 13, 2020, 4:08:16 AM4/13/20
to AdWords API and Google Ads API Forum
Hi, 

I am using the example code for update and Expanded Text and looks ok, but When I use something similar to ImageAd always I having the same response: 

[2020-04-13 10:04:42] AW_SOAP.WARNING: clientCustomerId=XXXXXXXXX operations=1 service=AdService method=mutate responseTime=182 requestId=0005a327891074600a37920489042c15 server=adwords.google.com isFault=1 faultMessage=[AdError.INVALID_AD_TYPE @ operations[0].operand.id]

$adService = $adWordsServices->get($session, AdService::class);

$operations = [];

$imageAd = new ImageAd();
$imageAd->setId($adGroupAd->getAd()->getId());

$imageAd->setName(date('YmdHis'));

$operation = new AdOperation();
$operation->setOperand($imageAd);
$operation->setOperator(Operator::SET);
$operations[] = $operation;

// Updates the ad on the server.
$result = $adService->mutate($operations);
$updatedAd = $result->getValue()[0];

If I set the type, AdType or both, the response is always the same.

Can you help me, please.?

Héctor Prieto

unread,
Apr 13, 2020, 7:23:06 AM4/13/20
to AdWords API and Google Ads API Forum
Hi I have found the response to my problem... 

Directly de ImageAd are not supported to mutate in the API in reference to https://developers.google.com/adwords/api/docs/guides/ad-features#ad_types_that_support_mutability 


--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/ad3c983c-6f5d-41c5-b8d3-fc212d85aa7d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages