Reuse uploaded image from MediaService when creating TemplateAd (templateId=432)

222 wyświetlenia
Przejdź do pierwszej nieodczytanej wiadomości

Chingiz Aitkul

nieprzeczytany,
10 cze 2014, 09:57:5710.06.2014
do adwor...@googlegroups.com
Hi there, I was able to create an Image TemplateAd (templateId=432) by directly creating a new Image via com.google.api.ads.common.lib.utils.Media.getMediaDataFromFile.

What I want to do now, is to reuse an Image I have previously uploaded via MediaService by its mediaId.

When I do this:

TemplateAd templateAd = new TemplateAd();
templateAd.setTemplateId(432L);
...
Image image = new Image();
image.setMediaId(image.getMediaId());
templateAd.setAdAsImage(newImage);

I get following request and error response. Could you please tell me why I get the error NullError.NULL_CONTENT? What am I doing wrong here?

Request:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201402" soapenv:mustUnderstand="0">
<ns1:clientCustomerId>5329326840</ns1:clientCustomerId>
<ns1:developerToken>some_developer_token</ns1:developerToken>
<ns1:userAgent>some_agent</ns1:userAgent>
<ns1:validateOnly>false</ns1:validateOnly>
<ns1:partialFailure>false</ns1:partialFailure>
</ns1:RequestHeader>
</soapenv:Header>
<soapenv:Body>
<mutate xmlns="https://adwords.google.com/api/adwords/cm/v201402">
<operations>
<operator>ADD</operator>
<operand>
<adGroupId>14655479043</adGroupId>
<ad xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201402" xsi:type="ns2:TemplateAd">
<ns2:url>some_url</ns2:url>
<ns2:displayUrl>some_display_url</ns2:displayUrl>
<ns2:templateId>432</ns2:templateId>
<ns2:templateElements>
<ns2:uniqueName>adData</ns2:uniqueName>
<ns2:fields>
<ns2:name>appId</ns2:name>
<ns2:type>TEXT</ns2:type>
<ns2:fieldText>some_app_id_text</ns2:fieldText>
</ns2:fields>
<ns2:fields>
<ns2:name>appStore</ns2:name>
<ns2:type>ENUM</ns2:type>
<ns2:fieldText>2</ns2:fieldText>
</ns2:fields>
</ns2:templateElements>
<ns2:adAsImage>
<ns2:mediaId>351043323</ns2:mediaId>
</ns2:adAsImage>
<ns2:dimensions>
<ns2:width>300</ns2:width>
<ns2:height>250</ns2:height>
</ns2:dimensions>
<ns2:name>some_ad_name</ns2:name>
</ad>
<status>PAUSED</status>
</operand>
</operations>
</mutate>
</soapenv:Body>
</soapenv:Envelope>

Respone:

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201402">
<requestId>0004fb7ba9c493000ae0ce41eb002b05</requestId>
<serviceName>AdGroupAdService</serviceName>
<methodName>mutate</methodName>
<operations>1</operations>
<responseTime>508</responseTime>
</ResponseHeader>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>[NullError.NULL_CONTENT @ operations[0].operand.ad.adAsImage]</faultstring>
<detail>
<ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201402">
<message>[NullError.NULL_CONTENT @ operations[0].operand.ad.adAsImage]</message>
<ApplicationException.Type>ApiException</ApplicationException.Type>
<errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="NullError">
<fieldPath>operations[0].operand.ad.adAsImage</fieldPath>
<trigger/>
<errorString>NullError.NULL_CONTENT</errorString>
<ApiError.Type>NullError</ApiError.Type>
<reason>NULL_CONTENT</reason>
</errors>
</ApiExceptionFault>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>

aitkul

nieprzeczytany,
11 cze 2014, 07:18:4611.06.2014
do adwor...@googlegroups.com
Sorry, typed wrong code im my post, what I tried was actually this:

TemplateAd templateAd = new TemplateAd();
templateAd.setTemplateId(432L);
...
Image image = new Image();
image.setMediaId(351043323);
templateAd.setAdAsImage(image);

Josh Radcliff (AdWords API Team)

nieprzeczytany,
11 cze 2014, 14:08:1011.06.2014
do adwor...@googlegroups.com
Hi,

From what I've found so far, when creating a TemplateAd and providing an Image object, you must populated the Image.data attribute directly -- you cannot simply provide a media ID.

The MediaService is only meant for:
  • Upload new images for location extensions.
  • Get the IDs of videos you want to use in template ads.
Cheers,
Josh, AdWords API Team

aitkul

nieprzeczytany,
12 cze 2014, 05:25:5412.06.2014
do adwor...@googlegroups.com
Hi Josh, thank you for the feedback. Yes, I already read in https://developers.google.com/adwords/api/docs/reference/v201402/MediaService that these two options can be used with MediaService, it is however stated "for example", so I thought MediaService can be used for all types of ads.

I guess, I am left with no other option but to first upload the Image via AdGroupAdService, and then copy it using TemplateAd#setOriginAdId() if I want to reuse it.

Vince NexonM

nieprzeczytany,
25 cze 2015, 02:51:4825.06.2015
do adwor...@googlegroups.com
Thank you for sharing this technique aitkul, I am able to copy an existing Template Ad that uses an Image from one campaign and copy it over to another different campaign using the same image as of v201502.
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0