We are trying to add user transactions to our Adwords campaigns. 

We are using the Python Suds API version v201708

Here is the error we are receiving

suds.WebFault: Server raised fault: 'Cannot construct an instance of 
com.google.ads.api.services.datax.offlinedataupload.UploadMetadata because 
it is abstract.  You are probably missing an @Uses annotation while 
invoking public abstract 
com.google.ads.api.services.datax.offlinedataupload.OfflineDataUploadReturnValue
 
...'


Any advice or a working example would be appreciated.

- Steve W.

The XML that was created by the API is:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
xmlns:tns="https://adwords.google.com/api/adwords/rm/v201708"; 
xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201708"; 
xmlns:ns2="https://adwords.google.com/api/adwords/rm/v201708"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
   <SOAP-ENV:Header>
      <tns:RequestHeader>
         <tns:clientCustomerId 
xmlns:tns="https://adwords.google.com/api/adwords/cm/v201708";>***-***-****</tns:clientCustomerId>
         <tns:developerToken 
xmlns:tns="https://adwords.google.com/api/adwords/cm/v201708";>*********************</tns:developerToken>
         <tns:userAgent 
xmlns:tns="https://adwords.google.com/api/adwords/cm/v201708";>Euclid 
AdAdmin (AwApi-Python, googleads/8.0.0, Python/2.7.10)</tns:userAgent>
         <tns:validateOnly 
xmlns:tns="https://adwords.google.com/api/adwords/cm/v201708";>false</tns:validateOnly>
         <tns:partialFailure 
xmlns:tns="https://adwords.google.com/api/adwords/cm/v201708";>false</tns:partialFailure>
      </tns:RequestHeader>
   </SOAP-ENV:Header>
   <ns0:Body>
      <ns2:mutate>
         <ns2:operations>
            <ns1:operator>ADD</ns1:operator>
            <ns2:operand>
               <ns2:uploadId>123</ns2:uploadId>
               <ns2:externalUploadId>456</ns2:externalUploadId>
              
 <ns2:uploadType>STORE_SALES_UPLOAD_THIRD_PARTY</ns2:uploadType>
               <ns2:uploadStatus/>
               <ns2:uploadMetadata xsi:type="ns2:ThirdPartyUploadMetadata">
                  <ns2:loyaltyRate>0.0</ns2:loyaltyRate>
                  <ns2:transactionUploadRate>0.0</ns2:transactionUploadRate>
                  
<ns2:advertiserUploadTime>01:05:00</ns2:advertiserUploadTime>
                  <ns2:validTransactionRate>0.0</ns2:validTransactionRate>
                  <ns2:partnerMatchRate>0.0</ns2:partnerMatchRate>
                  <ns2:partnerUploadRate>0.0</ns2:partnerUploadRate>
                  
<ns2:bridgeMapVersionId>bridgeId123</ns2:bridgeMapVersionId>
                  <ns2:partnerId>partnerId123</ns2:partnerId>
               </ns2:uploadMetadata>
               <ns2:offlineDataList>
                  <ns2:userIdentifiers>
                    
 <ns2:userIdentifierType>EXTERNAL_USER_ID</ns2:userIdentifierType>
                     <ns2:value>id123</ns2:value>
                  </ns2:userIdentifiers>
                  <ns2:transactionTime>2017-10-31 
17:30:00-08:00</ns2:transactionTime>
                  <ns2:transactionAmount>0</ns2:transactionAmount>
                  <ns2:conversionName></ns2:conversionName>
               </ns2:offlineDataList>
               <ns2:failureReason/>
            </ns2:operand>
         </ns2:operations>
      </ns2:mutate>
   </ns0:Body>
</SOAP-ENV:Envelope>


and here is the code

import datetime
from googleads import adwords
from googleads import oauth2
from httplib2 import Http
from oauth2client import client
import logging
import constants

logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG) # MUST BE THIS?
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
logging.getLogger('suds.resolver').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.query').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.basic').setLevel(logging.DEBUG)
logging.getLogger('suds.binding.marshaller').setLevel(logging.DEBUG)

scopes = ['https://www.googleapis.com/auth/adwords']


# Authorization

credentials = client.OAuth2Credentials(
    None, constants.CLIENT_ID, constants.CLIENT_SECRET, 
constants.REFRESH_TOKEN,
    datetime.datetime(2049, 1, 1, 12), constants.GOOGLE_OAUTH2_ENDPOINT,
    constants.USER_AGENT)
logging.warning(credentials)

# Adword Client

adwords_client = 
adwords.AdWordsClient.LoadFromStorage(constants.GOOGLEADS_YAML)
# logging.warning(adwords_client)

adwords_client.SetClientCustomerId(constants.CLIENT_CUSTOMER_ID)
# 
adwords_client.SetClientCustomerId(constants.POST_VISITS_AS_ZERO_DOLLAR_TRANSACTIONS_ACCOUNT_ID)
# logging.warning(adwords_client)

# OfflineDataUpload Operations
offline_data_upload_service = 
adwords_client.GetService('OfflineDataUploadService', 
version=constants.VERSION)

# User suds to make OfflineDataUploadService calls
suds_client = offline_data_upload_service.suds_client


# create a user identifier
user_identifier = suds_client.factory.create('UserIdentifier')
user_identifier.userIdentifierType = 'EXTERNAL_USER_ID'
user_identifier.value = 'id123'

# create a store sales transaction
store_sales_transaction = 
suds_client.factory.create('StoreSalesTransaction')
store_sales_transaction.userIdentifiers = [user_identifier]
store_sales_transaction.transactionTime = '2017-10-31 17:30:00-08:00'
store_sales_transaction.transactionAmount = 0
store_sales_transaction.conversionName = ''


# create 3rd party upload metadata
third_party_upload_metadata = 
suds_client.factory.create('ThirdPartyUploadMetadata')
third_party_upload_metadata.loyaltyRate = 0.0
third_party_upload_metadata.transactionUploadRate = 0.0
third_party_upload_metadata.advertiserUploadTime = '01:05:00'
third_party_upload_metadata.validTransactionRate = '0.0'
third_party_upload_metadata.partnerMatchRate = '0.0'
third_party_upload_metadata.partnerUploadRate = '0.0'
third_party_upload_metadata.bridgeMapVersionId = 'bridgeId123'
third_party_upload_metadata.partnerId = 'partnerId123'


offline_data_upload = suds_client.factory.create('OfflineDataUpload')
offline_data_upload.uploadId = 123
offline_data_upload.externalUploadId = 456
offline_data_upload.uploadType = 'STORE_SALES_UPLOAD_THIRD_PARTY'
offline_data_upload.uploadMetadata = third_party_upload_metadata
offline_data_upload.offlineDataList = [store_sales_transaction]


operation = suds_client.factory.create('OfflineDataUploadOperation')
operation.operator = 'ADD'
operation.operand = offline_data_upload

# The service object returned from the client.GetService() call accepts suds
# objects and will set the SOAP and HTTP headers for you.
response = offline_data_upload_service.mutate([operation])
logging.warning(response)
logging.warning(suds_client.last_sent())
logging.warning(suds_client.last_received())


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/19f4f22f-3590-474b-82ba-ac810513aaee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • Having difficult... Steve Wilhelm
    • Re: Having ... 'Vincent Racaza (AdWords API Team)' via AdWords API Forum

Reply via email to