Re: Having difficulties with OfflineDataUpload Python Suds v201708

2017-11-07 Thread 'Vincent Racaza (AdWords API Team)' via AdWords API Forum
Hi Steve,

Based on your SOAP request, it seems that there is something wrong on how 
you construct the UploadMetadata 

 object. 
Below is the correct SOAP request snippet with this object:


 https://adwords.google.com/api/adwords/cm/v201710";>ADD
 
 
 STORE_SALES_UPLOAD_FIRST_PARTY
 **
 <*StoreSalesUploadCommonMetadata* xmlns:ns8=
"https://adwords.google.com/api/adwords/rm/v201710"; xsi:type="ns8:
*ThirdPartyUploadMetadata*">
 0.0
 0.0
 
 **

Basically, the ThirdPartyUploadMetadata 

 is 
a type of StoreSalesUploadCommonMetadata 
,
 
so you need to create an object of type StoreSalesUploadCommonMetadata with 
an instance of ThirdPartyUploadMetadata. Apologies as I am not an expert in 
Python so I'll just provide a sample code snippet in Java so you can check 
how the object should be constructed:

  OfflineDataUpload offlineDataUpload = new OfflineDataUpload();
  offlineDataUpload.setExternalUploadId(externalUploadId);
  offlineDataUpload.setOfflineDataList(
  offlineDataList.toArray(new OfflineData[offlineDataList.size()]));

  offlineDataUpload.setUploadType(OfflineDataUploadType.
STORE_SALES_UPLOAD_FIRST_PARTY);
  
*UploadMetadata uploadMetadata = new UploadMetadata();  
StoreSalesUploadCommonMetadata store = new ThirdPartyUploadMetadata();*
  
  store.setLoyaltyRate(0.0);
  store.setTransactionUploadRate(0.0);
   
  uploadMetadata.setStoreSalesUploadCommonMetadata(store);
   
  offlineDataUpload.setUploadMetadata(uploadMetadata);

Kindly do the suggestion first and let me know if the issue persists. If it 
persists, then kindly provide your SOAP request and response logs via *Reply 
privately to author* option.

Thanks,
Vincent
AdWords API Team

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
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/8563da14-9867-4c30-99bb-8de01aa9f95a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Having difficulties with OfflineDataUpload Python Suds v201708

2017-11-07 Thread Steve Wilhelm
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:


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/";>
   
  
 https://adwords.google.com/api/adwords/cm/v201708";>***-***-
 https://adwords.google.com/api/adwords/cm/v201708";>*
 https://adwords.google.com/api/adwords/cm/v201708";>Euclid 
AdAdmin (AwApi-Python, googleads/8.0.0, Python/2.7.10)
 https://adwords.google.com/api/adwords/cm/v201708";>false
 https://adwords.google.com/api/adwords/cm/v201708";>false
  
   
   
  
 
ADD

   123
   456
  
 STORE_SALES_UPLOAD_THIRD_PARTY
   
   
  0.0
  0.0
  
01:05:00
  0.0
  0.0
  0.0
  
bridgeId123
  partnerId123
   
   
  

 EXTERNAL_USER_ID
 id123
  
  2017-10-31 
17:30:00-08:00
  0
  
   
   

 
  
   



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
o