Im using the API in order to upload keywords to adgroups.
I have ~100000 and when Im using the batch job service is too slow( 
sometimes the server crashs before).
I red the API documentation but cant find a better way that im using
My question is:
1. Is there a better way to upload all these content in batch job.
2. Is there a limit to upload operations in batch job.

This is my code(took from examples) in python:

def run_operations_as_batch_job(account_id, wait_for_response=False, 
    job_helper = adwords_client.GetBatchJobHelper()
    job = create_batch_job()
    upload_url = job['uploadUrl']['url']
    batch_job_id = job['id']

    job_helper.UploadOperations(upload_url, *operations)
    while wait_for_response:
            url = GetBatchJobDownloadUrlWhenReady(batch_job_id)
            response = urllib2.urlopen(url).read()
            return job_helper.ParseResponse(response)
    return batch_job_id

def GetBatchJobDownloadUrlWhenReady(batch_job_id, max_poll_attempts=10):
    batch_job = get_batch_job(batch_job_id)
    poll_attempt = 0
    while poll_attempt < max_poll_attempts and batch_job['status'] in ('DONE', 
        if 'downloadUrl' in batch_job:
            url = batch_job['downloadUrl']['url']
            print ('Batch Job with Id "%s", Status "%s", and DownloadUrl "%s" 
                   % (batch_job['id'], batch_job['status'], url))
            return url
        sleep_interval = (30 * (2 ** poll_attempt) +
                          (random.randint(0, 10000) / 1000))
        print 'Batch Job not ready, sleeping for %s seconds.' % sleep_interval
        batch_job = get_batch_job(batch_job_id)
        poll_attempt += 1

    raise Exception('Batch Job not finished downloading. Try checking later.')

def get_batch_job(batch_job_id):
    batch_job_service = get_service(Services.BATCH_JOB_SERVICE)
    selector = {
      'fields': ['Id', 'Status', 'DownloadUrl'],
      'predicates': [{'field': 'Id', 'operator': 'EQUALS', 'values': 
    return batch_job_service.get(selector)['entries'][0]

Also find us on our blog and Google+:

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
For more options, visit this group at
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 
For more options, visit https://groups.google.com/d/optout.

Reply via email to