Batch Job v201705

28 views
Skip to first unread message

Kanan Farzali

unread,
Jun 21, 2017, 4:27:09 AM6/21/17
to AdWords API Forum
Hi All,

I have updated my old code into the new version v201705.

//Bulk Adwords functions
public function createBatchJob($clientId, $operations) {
    $oAuth2Credential = (new OAuth2TokenBuilder())
        ->fromFile()
        ->build();

    // Construct an API session configured from a properties file and the OAuth2
    // credentials above.
    $session = (new AdWordsSessionBuilder())
        ->fromFile()
        ->withOAuth2Credential($oAuth2Credential)
        ->withClientCustomerId($clientId)
        ->build();

    $adWordsServices = new AdWordsServices();
    $batchJobService = $adWordsServices->get($session, BatchJobService::class);

    // Create a BatchJob.
    $addOp = new BatchJobOperation();
    $addOp->setOperator(Operator::ADD);
    $addOp->setOperand(new BatchJob());

    $result = $batchJobService->mutate([$addOp]);
    $batchJob = $result->getValue()[0];

    $uploadUrl = $batchJob->getUploadUrl()->getUrl();

    $batchJobs = new BatchJobs($session);

    $batchJobs->uploadBatchJobOperations($operations, $uploadUrl);

    if (!empty($batchJob->getUploadUrl()->getUrl())) {
        $jobDetails = new stdClass();
        $jobDetails->job_id = $batchJob->getId();
        $jobDetails->client_id = $clientId;

        return $jobDetails;
    }
}

The following code gets a unique batch job id but doesn't mutate objects (like pausing or unpausing campaigns) in Google Server. For example, I get batch job ids with status AWAITING FILE and it seems never changes.

Please help with it.

Thanks,

Kanan

Peter Oliquino

unread,
Jun 21, 2017, 5:11:07 AM6/21/17
to AdWords API Forum
Hi Kanan,

Could you confirm if those batch IDs are still on the AWAITING_FILE status? If yes, you could try and cancel the batch job and retry your request. If in your retry the status will still be stuck as AWAITING_FILE, please send to me your clientCustomerId and the batch job IDs so I can further investigate. Please also reply using Reply privately to author.

Best regards,
Peter
AdWords API Team
Reply all
Reply to author
Forward
0 new messages