Edit: I have found this key point: 
"Key Point: Create operations don't specify a resourceName or ID. When the 
API call succeeds, the response includes the resourceName generated for the 
newly created object." in this 
guide 
https://developers.google.com/google-ads/api/docs/rest/common/mutate#create

So the new request looks like this after changing *resourceName *to 
*campaignCriterion*
*curl --location -g --request POST 
'https://googleads.googleapis.com/v6/customers/{customer_id}/campaignCriteria:mutate
 
<https://googleads.googleapis.com/v6/customers/%7Bcustomer_id%7D/campaignCriteria:mutate>'
 
\*
*--header 'Authorization: Bearer {access_token}' \*
*--header 'developer-token: {developer token}' \*
*--header 'login-customer-id: 123456789' \*
*--header 'Content-Type: application/json' \*
*--data-raw '{*
*   "operations":[*
*      {*
*         "create":{*
*            
"campaignCriterion":"customers/{customer_id}/campaignCriteria/{campaign_id}~{random_generated_id}",*
*            "adSchedule":{*
*               "startMinute":"{scheduleDay.startMinute}",*
*               "endMinute":"{scheduleDay.endMinute}",*
*               "dayOfWeek":"{scheduleDay.dayOfWeek}",*
*               "startHour":"{scheduleDay.startHour}",*
*               "endHour":"{scheduleDay.endHour}"*
*            },*
*            "status":"ENABLED",*
*            "campaign":"{campaign_id}",*
*            "bidModifier":1.0*
*         }*
*      }*
*   ]*
*}'*

I also made the request with a few variations to fish out if I had a typo: 
*1- 
"campaignCriterion":"customers/{customer_id}/campaignCriteria/{campaign_id}~{random_generated_id}"*
*2- "campaignCriterion":"customers/{customer_id}/campaignCriteria"*
*3- "**campaignCriteria*
*":"customers/{customer_id}/campaignCriteria/{campaign_id}~{random_generated_id}"*
*4- "**campaignCriteria**":"customers/{customer_id}/campaignCriteria"*

The operation still does not work after these edits 



On Wednesday, February 3, 2021 at 3:03:03 PM UTC+10 Eylon Raymond Harari 
wrote:

> I am trying to create new a ad_schedule for a given campaign. 
>
>
> *Steps I have taken to achieve that: *1) Get all the existing ad_schedule 
> criteria - working ✅ 
> <https://emojipedia.org/check-mark-button/#:~:text=%E2%9C%85%20Check%20Mark%20Button&text=Shows%20on%20most%20platforms%20with,blue%20check%20mark%20%2F%20blue%20tick.&text=Check%20Mark%20Button%20was%20approved,to%20Emoji%201.0%20in%202015.>
>  
> 2) Remove all ad_schedule criteria to "clear the ground" before creating 
> new ones  - working ✅ 
> <https://emojipedia.org/check-mark-button/#:~:text=%E2%9C%85%20Check%20Mark%20Button&text=Shows%20on%20most%20platforms%20with,blue%20check%20mark%20%2F%20blue%20tick.&text=Check%20Mark%20Button%20was%20approved,to%20Emoji%201.0%20in%202015.>
> 3) Creation of new ad_schedule criteria - not working ❌ 
> <https://emojipedia.org/cross-mark/> 
>
> *Guides I am following: *
>
> https://developers.google.com/google-ads/api/reference/rpc/v6/CampaignCriterion
>
> https://developers.google.com/google-ads/api/reference/rpc/v6/AdScheduleInfo
>
> *Sample of curl request made for the creation of new ad_schedule 
> criteria: *
>
> *curl --location -g --request POST 
> 'https://googleads.googleapis.com/v6/customers/{customer_id}/campaignCriteria:mutate
>  
> <https://googleads.googleapis.com/v6/customers/%7Bcustomer_id%7D/campaignCriteria:mutate>'
>  
> \*
> *--header 'Authorization: Bearer {access_token}' \*
> *--header 'developer-token: {developer token}' \*
> *--header 'login-customer-id: 123456789' \*
> *--header 'Content-Type: application/json' \*
> *--data-raw '{*
> *   "operations":[*
> *      {*
> *         "create":{*
> *            
> "resourceName":"customers/{customer_id}/campaignCriteria/{campaign_id}~{random_generated_id}",*
> *            "adSchedule":{*
> *               "startMinute":"{scheduleDay.startMinute}",*
> *               "endMinute":"{scheduleDay.endMinute}",*
> *               "dayOfWeek":"{scheduleDay.dayOfWeek}",*
> *               "startHour":"{scheduleDay.startHour}",*
> *               "endHour":"{scheduleDay.endHour}"*
> *            },*
> *            "status":"ENABLED",*
> *            "campaign":"{campaign_id}",*
> *            "bidModifier":1.0*
> *         }*
> *      }*
> *   ]*
> *}'*
>
> I suspect it is not working because of the incorrect *"resourceName"*. I 
> was following this guide 
> <https://developers.google.com/google-ads/api/reference/rpc/v6/CampaignCriterion>,
>  
> which instructs to set the "resourceName" as such: 
> *customers/{customer_id}/campaignCriteria/{campaign_id}~{criterion_id}..*
>
> Currently, because it's a create operation I am randomly creating the 
> "criterion_id" as you can see in the CURL request
>
> I also tried to set the * "resourceName" *as only 
> *"customers/{customer_id}/campaignCriteria" 
> *but it didn't work as well... 
>
> What can I be missing here? 
>
> Thanks 👍
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/8e5327bd-0588-438a-980b-ab3baae36d14n%40googlegroups.com.

Reply via email to