How can i setImageMediaIds for UAC through api?

78 views
Skip to first unread message

gilbertmm...@gmail.com

unread,
Jul 19, 2018, 12:32:00 AM7/19/18
to AdWords API and Google Ads API Forum
hi,I use php api to setImageMediaIds for UAC,but i got error like this: MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN

I read the api doc said through Listoperations to set images,but i found no any code sample.
how i use listoperation?

thanks!


Luis Xander Talag (AdWords API Team)

unread,
Jul 19, 2018, 3:06:13 AM7/19/18
to AdWords API and Google Ads API Forum
Hi Gilbert,

To better investigate this, could you provide the complete SOAP request and response logs via reply privately to author when you encountered the error? To set your uploaded media to your UAC, you should use the CampaignService.UniversalAppCampaignSetting() method and set your mediaId to imageMediaIds field. 

For list of mediaId(s), you could put those mediaIds in a list using the CampaignService.ListOperations() method and set them in imageMediaIdsOps field of your UAC settings. You should take note that the number of operators in the ListOperations must be equal to the number of elements in the corresponding list. You may refer to below sample code snippet for your reference.

universalAppSetting.setImageMediaIds(new long[] {3358323767L,3359776773L});
listOperations.setOperators(new ListOperationsListOperator[] {ListOperationsListOperator.PUT, ListOperationsListOperator.PUT});
universalAppSetting.setImageMediaIdsOps(listOperations);

Thanks and regards,
Luis
AdWords API Team

gilbertmm...@gmail.com

unread,
Jul 19, 2018, 3:50:32 AM7/19/18
to AdWords API and Google Ads API Forum
hi Luis

this is my soap request and response
<?xml version="1.0" encoding="UTF-8"?>
        <SOAP-ENV:Header>
            <ns1:RequestHeader>
                <ns1:clientCustomerId>XXXXXXXX</ns1:clientCustomerId>
                <ns1:developerToken>bbbbb</ns1:developerToken>
                <ns1:userAgent>unknown (AwApi-PHP, googleads-php-lib/35.1.0, PHP/7.1.17)</ns1:userAgent>
                <ns1:validateOnly>false</ns1:validateOnly>
                <ns1:partialFailure>false</ns1:partialFailure>
            </ns1:RequestHeader>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
            <ns1:mutate>
                <ns1:operations>
                    <ns1:operator>ADD</ns1:operator>
                    <ns1:operand>
                        <ns1:name>test_name</ns1:name>
                        <ns1:status>PAUSED</ns1:status>
                        <ns1:startDate>20180720</ns1:startDate>
                        <ns1:endDate>20190719</ns1:endDate>
                        <ns1:budget>
                            <ns1:budgetId>1543</ns1:budgetId>
                        </ns1:budget>
                        <ns1:settings xsi:type="ns1:UniversalAppCampaignSetting">
                            <ns1:appId>app.app</ns1:appId>
                            <ns1:appVendor>VENDOR_GOOGLE_MARKET</ns1:appVendor>
                            <ns1:description1>111</ns1:description1>
                            <ns1:description2>222</ns1:description2>
                            <ns1:description3>333</ns1:description3>
                            <ns1:description4>444</ns1:description4>
                            <ns1:imageMediaIds>4304109512</ns1:imageMediaIds>
                            <ns1:imageMediaIds>4304135199</ns1:imageMediaIds>
                            <ns1:imageMediaIds>4304344038</ns1:imageMediaIds>
                            <ns1:universalAppBiddingStrategyGoalType>OPTIMIZE_FOR_INSTALL_CONVERSION_VOLUME</ns1:universalAppBiddingStrategyGoalType>
                            <ns1:imageMediaIdsOps>
                                <ns1:operators>PUT</ns1:operators>
                                <ns1:operators>PUT</ns1:operators>
                                <ns1:operators>PUT</ns1:operators>
                            </ns1:imageMediaIdsOps>
                        </ns1:settings>
                        <ns1:settings xsi:type="ns1:GeoTargetTypeSetting">
                            <ns1:negativeGeoTargetType>LOCATION_OF_PRESENCE</ns1:negativeGeoTargetType>
                        </ns1:settings>
                        <ns1:advertisingChannelType>MULTI_CHANNEL</ns1:advertisingChannelType>
                        <ns1:advertisingChannelSubType>UNIVERSAL_APP_CAMPAIGN</ns1:advertisingChannelSubType>
                        <ns1:biddingStrategyConfiguration>
                            <ns1:biddingStrategyType>TARGET_CPA</ns1:biddingStrategyType>
                            <ns1:biddingScheme xsi:type="ns1:TargetCpaBiddingScheme">
                                <ns1:targetCpa>
                                    <ns1:microAmount>800000</ns1:microAmount>
                                </ns1:targetCpa>
                            </ns1:biddingScheme>
                        </ns1:biddingStrategyConfiguration>
                    </ns1:operand>
                </ns1:operations>
            </ns1:mutate>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


and reponse:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
        <ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201802">
            <requestId>000571551f1a85c00a62a6886704a389</requestId>
            <serviceName>CampaignService</serviceName>
            <methodName>mutate</methodName>
            <operations>1</operations>
            <responseTime>222</responseTime>
        </ResponseHeader>
    </soap:Header>
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Client</faultcode>
            <faultstring>[SettingError.MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN @ operations[0].operand.settings[0].imageMediaIds[6]; trigger:'4307215387', SettingError.MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN @ operations[0].operand.settings[0].imageMediaIds[0]; trigger:'4304109512', SettingError.MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN @ operations[0].operand.settings[0].imageMediaIds[3]; trigger:'4304123177']</faultstring>
            <detail>
                <ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201802">
                    <message>[SettingError.MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN @ operations[0].operand.settings[0].imageMediaIds[6]; trigger:'4307215387', SettingError.MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN @ operations[0].operand.settings[0].imageMediaIds[0]; trigger:'4304109512', SettingError.MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN @ operations[0].operand.settings[0].imageMediaIds[3]; trigger:'4304123177', SettingError.MEDIA_I]</message>
                    <ApplicationException.Type>ApiException</ApplicationException.Type>
                    <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SettingError">
                        <fieldPath>operations[0].operand.settings[0].imageMediaIds[6]</fieldPath>
                        <fieldPathElements>
                            <field>operations</field>
                            <index>0</index>
                        </fieldPathElements>
                        <fieldPathElements>
                            <field>operand</field>
                        </fieldPathElements>
                        <fieldPathElements>
                            <field>settings</field>
                            <index>0</index>
                        </fieldPathElements>
                        <fieldPathElements>
                            <field>imageMediaIds</field>
                            <index>6</index>
                        </fieldPathElements>
                        <trigger>4307215387</trigger>
                        <errorString>SettingError.MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN</errorString>
                        <ApiError.Type>SettingError</ApiError.Type>
                        <reason>MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN</reason>
                    </errors>
                    <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SettingError">
                        <fieldPath>operations[0].operand.settings[0].imageMediaIds[0]</fieldPath>
                        <fieldPathElements>
                            <field>operations</field>
                            <index>0</index>
                        </fieldPathElements>
                        <fieldPathElements>
                            <field>operand</field>
                        </fieldPathElements>
                        <fieldPathElements>
                            <field>settings</field>
                            <index>0</index>
                        </fieldPathElements>
                        <fieldPathElements>
                            <field>imageMediaIds</field>
                            <index>0</index>
                        </fieldPathElements>
                        <trigger>4304109512</trigger>
                        <errorString>SettingError.MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN</errorString>
                        <ApiError.Type>SettingError</ApiError.Type>
                        <reason>MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN</reason>
                    </errors>
                    <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SettingError">
                        <fieldPath>operations[0].operand.settings[0].imageMediaIds[3]</fieldPath>
                        <fieldPathElements>
                            <field>operations</field>
                            <index>0</index>
                        </fieldPathElements>
                        <fieldPathElements>
                            <field>operand</field>
                        </fieldPathElements>
                        <fieldPathElements>
                            <field>settings</field>
                            <index>0</index>
                        </fieldPathElements>
                        <fieldPathElements>
                            <field>imageMediaIds</field>
                            <index>3</index>
                        </fieldPathElements>
                        <trigger>4304123177</trigger>
                        <errorString>SettingError.MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN</errorString>
                        <ApiError.Type>SettingError</ApiError.Type>
                        <reason>MEDIA_INCOMPATIBLE_FOR_UNIVERSAL_APP_CAMPAIGN</reason>
                    </errors>
                </ApiExceptionFault>
            </detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>




here is my code 
foreach ($data['media'] as $val){
$ids[] = intval($val);
$ops[] = ListOperationsListOperator::PUT;
}
$universalAppSetting->setImageMediaIds($ids);
$listOperation = new ListOperations();
$listOperation->setOperators($ops);
$universalAppSetting->setImageMediaIdsOps($listOperation);



how i can fix this?
thanks.

Luis Xander Talag (AdWords API Team)

unread,
Jul 19, 2018, 6:13:32 AM7/19/18
to AdWords API and Google Ads API Forum
Hi Gilbert,

Thank you for providing the logs. I believe your request is correct. However, could you confirm if the media Ids that you are setting are indeed landscape images? Other media type like HTML5, videos, media bundle etc. are currently not supported for uploading in UAC via the API. If you could confirm that those are indeed landscape images media, let me know so I could further investigate the issue.

Regards,
Luis
AdWords API Team

Reply all
Reply to author
Forward
0 new messages