private static String addCampaignBudget(GoogleAdsClient googleAdsClient, long 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?Request
-------
MethodName: google.ads.googleads.v18.services.CampaignBudgetService/MutateCampaignBudgets
Endpoint:
googleads.googleapis.com:443Headers: {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
}
}