I followed the example and used manual_cpc to submit, but received the 
following error:

Status: Status{code=INVALID_ARGUMENT, description=Request contains an 
invalid argument., cause=null}.
Request ID LL0nxm7nhofyon6GNdtVXg 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: "mutate_operations"
    index: 1
  }
  field_path_elements {
    field_name: "campaign_operation"
  }
  field_path_elements {
    field_name: "create"
  }
  field_path_elements {
    field_name: "manual_cpc"
  }
}

  Error 1: error_code {
  mutate_error: RESOURCE_NOT_FOUND
}

My code is as follows:

private CampaignOperation createDemandGenCampaignOperation(
String campaignResourceName, String budgetResourceName, String 
biddingStrategyResourceName) {
// [START add_demand_gen_campaign_2]
// Creates the campaign.
Campaign campaign =
Campaign.newBuilder()
.setResourceName(campaignResourceName)
.setName("Test - Demand Gen campaign " + System.currentTimeMillis())
// Demand Gen campaigns are supported in the DEMAND_GEN channel.
.setAdvertisingChannelType(AdvertisingChannelType.DEMAND_GEN)
// Sets the campaign status to PAUSED. The campaign is enabled later.
.setStatus(CampaignStatus.PAUSED)
.setCampaignBudget(budgetResourceName)
// Declares whether this campaign serves political ads targeting the EU.
.setContainsEuPoliticalAdvertising(DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
)
// Sets the bidding strategy.
.setManualCpc(ManualCpc.newBuilder().build())
.build();

// Creates the operation.
return CampaignOperation.newBuilder().setCreate(campaign).build();
// [END add_demand_gen_campaign_2]
}

How to solve it?

在2025年8月19日星期二 UTC+8 05:53:22<Google Ads API Forum Advisor> 写道:

> Hi,
>
> Kindly disregard my previous email. Thank you for reaching out to the 
> Google Ads API support team.
>
>
> From the provided image, the clicks uses the cpc bid strategy. I would 
> recommend that you set the bidstrategy to manual_cpc 
> <https://developers.google.com/google-ads/api/reference/rpc/v21/Campaign#:~:text=Local%20Services%20campaigns.-,manual_cpc,-ManualCpc>.
>  
> Kindly refer to this code example 
> <https://developers.google.com/google-ads/api/docs/campaigns/create-campaigns#php:~:text=%27manual_cpc%27%20%3D%3E%20new%20ManualCpc()%2C>.
>  
> Also, to assist your further with the code, could you please provide us 
> with the complete API logs (request 
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#request>
>  and response 
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#response>
>  logs with request-id 
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id>
>  and request header 
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request_headers>)
>  
> generated at your end. This would help us understand the issue and assist 
> you accordingly.
>
> If you are using a client library and haven't enabled the logging yet, I 
> would request you to enable logging for the specific client library that 
> you are using. You can refer to the guides Java 
> <https://developers.google.com/google-ads/api/docs/client-libs/java/logging>
> , .Net 
> <https://developers.google.com/google-ads/api/docs/client-libs/dotnet/logging>
> , PHP 
> <https://developers.google.com/google-ads/api/docs/client-libs/php/logging>
> , Python 
> <https://developers.google.com/google-ads/api/docs/client-libs/python/logging>
> , Ruby 
> <https://developers.google.com/google-ads/api/docs/client-libs/ruby/logging>
>  or Perl 
> <https://developers.google.com/google-ads/api/docs/client-libs/perl/logging> 
> to 
> enable logging at your end. For REST interface requests, you can 
> enable logging via the curl command by using the -i flag.
>
> You can send the details via *Reply privately* to the author option, or 
> direct private reply to this email. 
>
> Thanks,
>   
> [image: Google Logo] Google Ads API Team 
> Feedback
> How was our support today? 
>
> [image: rating1] 
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=1&entry.295079254=500Ht00001szPi2IAE>
>   
>   [image: rating2] 
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=2&entry.295079254=500Ht00001szPi2IAE>
>   
>   [image: rating3] 
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=3&entry.295079254=500Ht00001szPi2IAE>
>   
>   [image: rating4] 
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=4&entry.295079254=500Ht00001szPi2IAE>
>   
>   [image: rating5] 
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=5&entry.295079254=500Ht00001szPi2IAE>
>
> [2025-08-18 21:52:40Z GMT] This message is in relation to case 
> "ref:!00D1U01174p.!500Ht01szPi2:ref" (ADR-00330269)
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/adwords-api/830ae0ee-e950-41a1-998d-ffb84d3a95cdn%40googlegroups.com.
  • De... Ashish Chaturvedi (Ashu)
    • ... flywheel
    • ... flywheel
      • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
        • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum

Reply via email to