Can't set DYNAMIC_IMAGE MediaType when uploading animated GIF image via MediaService

87 views
Skip to first unread message

Chingiz Aitkul

unread,
Jun 6, 2014, 12:08:42 PM6/6/14
to adwor...@googlegroups.com
Hi there, I am trying to upload an animated GIF Image via upload() method of MediaService using example code provided with Java library for AdWords API. When I upload a static GIF or JPEG file it works ok.

When I try to upload an animated GIF Image, the Service replies with a MediaID without any errors, but when I query for all available media files, I don't recieve any entries for the animated GIF Images, only the static Image Uploads I retrieved.

I noticed that in the example code (adwords.axis.v201402.misc.UploadImage.java) the MediaType of the Image is set before uploading to MediaMediaType,IMAGE. So I Change it to MediaMediaType.DYNAMIC_IMAGE, and when I do so, I get the following error.

Could you please advice, if this is a bug or I am doing something wrong here?

<?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>0004fb2cc9f931980ae06184c4000fa2</requestId>
            <serviceName>MediaService</serviceName>
            <methodName>upload</methodName>
            <operations>1</operations>
            <responseTime>600</responseTime>
        </ResponseHeader>
    </soap:Header>
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Server</faultcode>
            <faultstring>[MediaError.UNSUPPORTED_OPERATION @ media[0].type]</faultstring>
            <detail>
                <ApiExceptionFault xmlns="
https://adwords.google.com/api/adwords/cm/v201402">
                    <message>[MediaError.UNSUPPORTED_OPERATION @ media[0].type]</message>
                    <ApplicationException.Type>ApiExceptionException in thread "main" </ApplicationException.Type>
                    <errors xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:type="MediaError">
                        <fieldPath>media[0].type</fieldPath>
                        <trigger/>
                        <errorString>MediaError.UNSUPPORTED_OPERATION</errorString>
                        <ApiError.Type>MediaError</ApiError.Type>
                        <reason>UNSUPPORTED_OPERATION</reason>
                    </errors>
                </ApiExceptionFault>
            </detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
 faultSubcode:
 faultString: [MediaError.UNSUPPORTED_OPERATION @ media[0].type]
 faultActor:
 faultNode:
 faultDetail:
 {https://adwords.google.com/api/adwords/cm/v201402}ApiExceptionFault:<message>[MediaError.UNSUPPORTED_OPERATION @ media[0].type]</message><ApplicationException.Type>ApiException</ApplicationException.Type><errors xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:type="MediaError"><fieldPath>media[0].type</fieldPath><trigger/><errorString>MediaError.UNSUPPORTED_OPERATION</errorString><ApiError.Type>MediaError</ApiError.Type><reason>UNSUPPORTED_OPERATION</reason></errors>
[MediaError.UNSUPPORTED_OPERATION @ media[0].type]
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
 at java.lang.Class.newInstance(Class.java:433)
 at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
 at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
 at com.google.api.ads.adwords.axis.v201402.cm.ApiException.getDeserializer(ApiException.java:143)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:483)
 at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
 at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
 at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
 at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
 at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
 at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
 at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
 at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:378)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2770)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
 at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
 at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
 at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
 at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
 at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:333)
 at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
 at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
 at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
 at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
 at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
 at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
 at org.apache.axis.client.Call.invoke(Call.java:2767)
 at org.apache.axis.client.Call.invoke(Call.java:2443)
 at org.apache.axis.client.Call.invoke(Call.java:2366)
 at org.apache.axis.client.Call.invoke(Call.java:1812)
 at com.google.api.ads.adwords.axis.v201402.cm.MediaServiceSoapBindingStub.upload(MediaServiceSoapBindingStub.java:816)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:483)
 at com.google.api.ads.common.lib.soap.SoapClientHandler.invoke(SoapClientHandler.java:109)
 at com.google.api.ads.common.lib.soap.axis.AxisHandler.invokeSoapCall(AxisHandler.java:201)
 at com.google.api.ads.common.lib.soap.SoapServiceClient.callSoapClient(SoapServiceClient.java:64)
 at com.google.api.ads.common.lib.soap.SoapServiceClient.invoke(SoapServiceClient.java:93)
 at com.sun.proxy.$Proxy14.upload(Unknown Source)
 at adwords.axis.v201402.misc.UploadImage.runExample(UploadImage.java:81)
 at adwords.axis.v201402.misc.UploadImage.main(UploadImage.java:60)

Josh Radcliff (AdWords API Team)

unread,
Jun 9, 2014, 2:26:32 PM6/9/14
to adwor...@googlegroups.com
Hi,

The UI supports a wide variety of ads, but the API may not necessarily support every one of these formats. As a starting point, have you tried creating the ad through the UI using the image in question? If the UI won't create the ad, then the API will not either.

Also, the MediaService is meant for usage with template ads, which does not include ImageAds. If you want to create an ImageAd you'll have to skip MediaService altogether and pass the image data directly on the ImageAd.image.data field in your AdGroupAdService request.

Cheers,
Josh, AdWords API Team

Chingiz Aitkul

unread,
Jun 10, 2014, 9:29:50 AM6/10/14
to adwor...@googlegroups.com
Hi, yes I can create the ad using UI with the very same animated gif Image.

Actually I can upload the Image via MediaService, and get a generated mediaId. The problem is that the Image media is not retrievable after that. On the other hand, when I upload a static GIF or JPEG Image, it is always retrievable via MediaService after that. The Java example code from google sets the media type as MediaMediaType.IMAGE, before uploading via MediaService, so I tried to set MediaMediaType.DYNAMIC_IMAGE instead, which generated an error I posted above.

The question is, why does MediaService reply with ok when I upload an animated GIF Image by specifying media type IMAGE, but then somehow "forget" it? If it is media type DYNAMIC_IMAGE, i should use when uploading animated GIFs, why do I get error from MediaService?

Josh Radcliff (AdWords API Team)

unread,
Jun 10, 2014, 9:35:36 AM6/10/14
to adwor...@googlegroups.com
Hi,

Thanks for clarifying. At this point I think it would be best if I could look at your particular account. Could you send the following only to me by clicking Reply to Author?

1. Your customer ID
2. The mediaIds of the images you've uploaded
3. The image file you uploaded
4. Any request/response logs that may be helpful

Also, how do you ultimately want to use the image? In a template ad or in an image ad?

Thanks,
Josh, AdWords API Team

Josh Radcliff (AdWords API Team)

unread,
Jun 11, 2014, 2:09:47 PM6/11/14
to adwor...@googlegroups.com
Hi,

Please see my reply to your other post. Let's continue the discussion on that post if you have further questions.

Cheers,
Josh, AdWords API Team

Layne Shepherd

unread,
Feb 22, 2018, 6:47:24 PM2/22/18
to AdWords API Forum
I'm getting the same error, 3+ years later.  Would be nice if you guys posted the solution here instead of just let me take a look at your account with no information posted thereafter...

Josh Radcliff (AdWords API Team)

unread,
Feb 25, 2018, 9:05:27 AM2/25/18
to AdWords API Forum
Hi,

My other post from around the same time sheds some light on this and suggests inlining the image data instead of passing a mediaId. Have you tried that approach?

Thanks,
Josh, AdWords API Team

Layne Shepherd

unread,
Feb 26, 2018, 12:15:08 PM2/26/18
to AdWords API Forum
I'm uploading new images, inlining image data, and it still gets rejected when using DYNAMIC_IMAGE.  The only way I can upload is to use IMAGE for MediaType.  These were animated gifs, so I'm wondering what DYNAMIC_IMAGE is even used for (has it ever worked?) if I can't upload an animated gif to MediaService -- it certainly doesn't work as advertised in the API documentation.

DYNAMIC_IMAGEAnimated image, such as animated GIF.
IMAGEStatic image; for image ad.

Josh Radcliff (AdWords API Team)

unread,
Feb 27, 2018, 11:32:59 AM2/27/18
to AdWords API Forum
Hi,

While I look into this, are your ads working as expected when you upload the animated gifs as IMAGE?

The MediaService documentation lists all media types, but some of those types are only supported in get or query requests, such as VIDEO. It may be that DYNAMIC_IMAGE falls into the read-only category as well. I'll find out if that's the case, and if so, have our documentation updated accordingly.

Thanks,
Josh, AdWords API Team

Layne Shepherd

unread,
Feb 27, 2018, 6:12:39 PM2/27/18
to AdWords API Forum
Yes, it works as expected when we upload with IMAGE.  

If you can't use VIDEO when uploading an actual video, then what MediaType do you use?  Documentation says it is required for an ADD operation using MediaService.upload.

Josh Radcliff (AdWords API Team)

unread,
Feb 28, 2018, 8:28:11 AM2/28/18
to AdWords API Forum
Hi,

Glad to hear the animated gif is working for you. Regarding VIDEO, you can only retrieve videos from MediaService. You cannot upload videos. This is mentioned in the documentation for the upload method, but we're about to improve the documentation at the service level to help clarify this point. If you want to upload videos, you will have to use the user interface.

Thanks,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages