addCampaignBudget error

34 views
Skip to first unread message

pj sheng

unread,
Nov 13, 2024, 4:18:34 AM11/13/24
to Google Ads API and AdWords API Forum
when i  add CampaignBudget like this :

private static 
String addCampaignBudget(GoogleAdsClient googleAdsClientlong customerId{
CampaignBudget budget =
CampaignBudget.newBuilder()
.setName("Cruise Budget #123" )
.setDeliveryMethod(BudgetDeliveryMethod.STANDARD)
.setAmountMicros(500_000L)
.build();

CampaignBudgetOperation op = CampaignBudgetOperation.newBuilder().setCreate(budget).build();
try (CampaignBudgetServiceClient campaignBudgetServiceClient =
googleAdsClient.getLatestVersion().createCampaignBudgetServiceClient(){
MutateCampaignBudgetsResponse response =
campaignBudgetServiceClient.mutateCampaignBudgets(
"1949217405", ImmutableList.of(op));
String budgetResourceName response.getResults(0).getResourceName();
System.out.printf("Added budget: %s%n"budgetResourceName);
return budgetResourceName;
}
}




returns  OPERATION_NOT_PERMITTED_FOR_CONTEXT


Is there something wrong with my parameters?

The following is my error log:
Request
-------
MethodName: google.ads.googleads.v18.services.CampaignBudgetService/MutateCampaignBudgets
Endpoint: googleads.googleapis.com:443
Headers: {developer-token=REDACTED, x-goog-api-client=gl-java/1.8.0_152__Oracle-Corporation gccl/34.0.0 gapic/34.0.0 gax/2.53.0 grpc/1.66.0}
Body: customer_id: "1949217405"
operations {
  create {
    delivery_method: STANDARD
    name: "Cruise Budget #123"
    amount_micros: 500000
  }
}


Response
--------
Headers: Metadata(content-type=application/grpc,request-id=QiJMjKCV82dA9zeUyLwYAg,date=Wed, 13 Nov 2024 04:19:35 GMT,alt-svc=h3=":443"; ma=2592000,h3-29=":443"; ma=2592000)
Body: null
Failure message: errors {
  error_code {
    context_error: OPERATION_NOT_PERMITTED_FOR_CONTEXT
  }
  message: "The operation is not allowed for the given context."
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
  }
}
request_id: "QiJMjKCV82dA9zeUyLwYAg"

Status: Status{code=INVALID_ARGUMENT, description=Request contains an invalid argument., cause=null}.
Request ID QiJMjKCV82dA9zeUyLwYAg failed due to GoogleAdsException. Underlying errors:
  Error 0: error_code {
  context_error: OPERATION_NOT_PERMITTED_FOR_CONTEXT
}
message: "The operation is not allowed for the given context."
location {
  field_path_elements {
    field_name: "operations"
    index: 0
  }
}

Google Ads API Forum Advisor

unread,
Nov 13, 2024, 9:24:08 AM11/13/24
to sheng...@gmail.com, adwor...@googlegroups.com

Hi,

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

From the provided logs, I understand that you've encountered the "OPERATION_NOT_PERMITTED_FOR_CONTEXT" error while trying to create the CampaignBudget. This error indicates that the operation is not allowed for the given context. Kindly note that you are using the MCC account for creating the CampaignBudget. So that you are getting this error. I would recommend you to use the client account while creating the CampaignBudget to avoid this error. 

If you have any errors even after following the given suggestions, please feel free to get back to us.

This message is in relation to case "ref:!00D1U01174p.!5004Q02vGjjm:ref" (ADR-00275460)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages