Ending the active account budget issue

34 views
Skip to first unread message

Алексей Рябиков

unread,
Jan 31, 2023, 2:04:53 AM1/31/23
to Google Ads API and AdWords API Forum
Hello! 

I'm trying to set the end time to active budget but, unfortunately, with no success. 

And here is my code (inside function, of course):
$accountBudgetProposal = new AccountBudgetProposal([
  'proposal_type' => AccountBudgetProposalType::END,
  'account_budget' => '6885573946' //budget id ?
]);
$accountBudgetProposalOperation = new AccountBudgetProposalOperation();
$accountBudgetProposalOperation->setCreate($accountBudgetProposal);

It does not return any errors but doesn't work too



Google Ads API Forum Advisor

unread,
Jan 31, 2023, 10:39:19 AM1/31/23
to house...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

With regards to your concern, can you please provide first the complete request and response logs with request ID and request header generated on your end so our team can provide guidance accordingly? If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library > Logging documentation, which you can access from this link.

You may then send the requested logs via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Regards,
Google Logo
Carmela
Google Ads API Team
 


ref:_00D1U1174p._5004Q2iPitT:ref

Алексей Рябиков

unread,
Feb 1, 2023, 10:37:37 AM2/1/23
to Google Ads API and AdWords API Forum
Hi! Thnx for recommendation. I'll and came back with information

вторник, 31 января 2023 г. в 18:39:19 UTC+3, adsapi:

Алексей Рябиков

unread,
Feb 10, 2023, 12:20:09 PM2/10/23
to Google Ads API and AdWords API Forum
Hi! 

Sorry for delay. 

I've enabled logger in configuration file but it doesnt work in this case (and works with all library examples), or my script does not send the request. 

Here is my code, that based on example "add budget proposal" and https://developers.google.com/google-ads/api/docs/billing/account-budgets?hl=en#end this code from docs.

<?php



namespace Google\Ads\GoogleAds\Examples\Billing;

require __DIR__ . '/../../vendor/autoload.php';

use GetOpt\GetOpt;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentNames;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentParser;
use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder;
use Google\Ads\GoogleAds\Lib\V12\GoogleAdsClient;
use Google\Ads\GoogleAds\Lib\V12\GoogleAdsClientBuilder;
use Google\Ads\GoogleAds\Lib\V12\GoogleAdsException;
use Google\Ads\GoogleAds\Util\V12\ResourceNames;
use Google\Ads\GoogleAds\V12\Enums\AccountBudgetProposalTypeEnum\AccountBudgetProposalType;
use Google\Ads\GoogleAds\V12\Enums\TimeTypeEnum\TimeType;
use Google\Ads\GoogleAds\V12\Errors\GoogleAdsError;
use Google\Ads\GoogleAds\V12\Resources\AccountBudgetProposal;
use Google\Ads\GoogleAds\V12\Services\AccountBudgetProposalOperation;
use Google\ApiCore\ApiException;

/**
 * This example creates an account budget proposal using the 'CREATE' operation. To get account
 * budget proposals, run GetAccountBudgetProposals.php
 */
class AddAccountBudgetProposal
{
    private const CUSTOMER_ID = '3721199407';
    private const BILLING_SETUP_ID = '6885573946';

    public static function main()
    {
        // Either pass the required parameters for this example on the command line, or insert them
        // into the constants above.
        $options = (new ArgumentParser())->parseCommandArguments([
            ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT,
            ArgumentNames::BILLING_SETUP_ID => GetOpt::REQUIRED_ARGUMENT
        ]);

        // Generate a refreshable OAuth2 credential for authentication.
        $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();

        // Construct a Google Ads client configured from a properties file and the
        // OAuth2 credentials above.
        $googleAdsClient = (new GoogleAdsClientBuilder())->fromFile()
            ->withOAuth2Credential($oAuth2Credential)
            ->build();

        try {
            self::runExample(
                $googleAdsClient,
                $options[ArgumentNames::CUSTOMER_ID] ?: self::CUSTOMER_ID,
                $options[ArgumentNames::BILLING_SETUP_ID] ?: self::BILLING_SETUP_ID
            );
        } catch (GoogleAdsException $googleAdsException) {
            printf(
                "Request with ID '%s' has failed.%sGoogle Ads failure details:%s",
                $googleAdsException->getRequestId(),
                PHP_EOL,
                PHP_EOL
            );
            foreach ($googleAdsException->getGoogleAdsFailure()->getErrors() as $error) {
                /** @var GoogleAdsError $error */
                printf(
                    "\t%s: %s%s",
                    $error->getErrorCode()->getErrorCode(),
                    $error->getMessage(),
                    PHP_EOL
                );
            }
            exit(1);
        } catch (ApiException $apiException) {
            printf(
                "ApiException was thrown with message '%s'.%s",
                $apiException->getMessage(),
                PHP_EOL
            );
            exit(1);
        }
    }

    /**
     * Runs the example.
     *
     * @param GoogleAdsClient $googleAdsClient the Google Ads API client
     * @param int $customerId the customer ID
     * @param int $billingSetupId the billing setup ID used to add the account budget proposal
     */
    // [START add_account_budget_proposal]
    public static function runExample(
        GoogleAdsClient $googleAdsClient,
        int $customerId,
        int $billingSetupId
    ) {
        // Constructs an account budget proposal.



       
       
$accountBudgetProposal = new AccountBudgetProposal([
'billing_setup' => ResourceNames::forBillingSetup($customerId, $billingSetupId),
  'proposal_type' => AccountBudgetProposalType::END,
  'account_budget' => 'customers/3721199407/accountBudgets/6885650342'

]);
$accountBudgetProposalOperation = new AccountBudgetProposalOperation();
$accountBudgetProposalOperation->setCreate($accountBudgetProposal);


    }
    // [END add_account_budget_proposal]
}

AddAccountBudgetProposal::main();

?>



I'm sure, that I did something wrong, but idk what could be wrong

Can you help me please? 

среда, 1 февраля 2023 г. в 18:37:37 UTC+3, Алексей Рябиков:

Google Ads API Forum Advisor

unread,
Feb 13, 2023, 1:09:55 AM2/13/23
to house...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for your reply.

Upon checking the provided information, it appears that your code snippet are more on related for PHP client library, I would suggest to reach out to the author of this client library via this github issues tracker as they can help you to enable your logging and to provide the API logs. 

Best regards,
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2iPitT:ref
Reply all
Reply to author
Forward
0 new messages