Here are example of curl command: 

*Campaign creation:*
curl -X POST \
  
'https://googleads.googleapis.com/v15/<CUSTOMER_RESSOURCE_NAME>/campaignCriteria:mutate'
 
\
  -H 'Content-Type: application/json' \
  -H 'developer-token: <DEVELOPER_TOKEN>' \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'login-customer-id: <MANAGER_ID>' \
  -d '{
    "operations": [
      {
        "create": {
          "negative": false,
          "campaign": "<CUSTOMER_RESSOURCE_NAME>/campaigns/21005342630",
          "type": "GENDER",
          "gender": {
            "type": "FEMALE"
          }
        }
      }
    ]
  }'
{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": 
"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure",
        "errors": [
          {
            "errorCode": {
              "criterionError": "FIELD_INCOMPATIBLE_WITH_NEGATIVE_TARGETING"
            },
            "message": "The field is not allowed to be set when the 
negative field is set to true, for example, we don't allow bids in negative 
ad group or campaign criteria.",
            "location": {
              "fieldPathElements": [
                {
                  "fieldName": "operations",
                  "index": 0
                },
                {
                  "fieldName": "create"
                },
                {
                  "fieldName": "gender"
                }
              ]
            }
          }
        ],
        "requestId": "jex36XGZqBA5l1VJ6X2mgA"
      }
    ]
  }
}


*Update Criteria (when created with negative define true):*
curl -X POST \
  
'https://googleads.googleapis.com/v15/<CUSTOMER_RESSOURCE_NAME>/campaignCriteria:mutate'
 
\
  -H 'Content-Type: application/json' \
  -H 'developer-token: <DEVELOPER_TOKEN>' \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'login-customer-id: <MANAGER_ID>' \
  -d '{
    "operations": [
      {
        "updateMask": "gender.type",
        "update": {
          "negative": false,
          "resourceName": 
"<CUSTOMER_RESSOURCE_NAME>/campaignCriteria/21005342630~10",
          "gender": {
             "type": "FEMALE"
          }
        }
      }
    ]
  }'
{
  "results": [
    {
      "resourceName": 
"<CUSTOMER_RESSOURCE_NAME>/campaignCriteria/21005342630~10"
    }
  ]
}

The response is positive but when i want to get the campaign criteria info 
using a GAQL, the criteria isn't update. Moreover *negative* isn't 
available in the *updateMask* field

*Campaign data (Criteria):*
"campaignCriterion":[{"campaignCriterion":{"resourceName":"<CUSTOMER_RESSOURCE_NAME>/campaignCriteria/21005342630~10","type":"GENDER","gender":{"type":"MALE"},"campaign":"<CUSTOMER_RESSOURCE_NAME>/campaigns/21005342630","criterionId":"10","negative":true}},
 
... ],

Tell me if you need more information

Le mercredi 7 février 2024 à 14:20:00 UTC+1, Google Ads API Forum Advisor a 
écrit :

> Hi,
>
> Thank you for reaching out to the Google Ads API support team.
>
> By reviewing your query, I understand that you are getting an error when 
> trying to update the criterion to negative false. In order to investigate 
> the issue, provide us with the updated 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>
>  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.
>
> 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.
>   
> This message is in relation to case "ref:!00D1U01174p.!5004Q02rytfz:ref"
>
> Thanks,
>   
> [image: Google Logo] Google Ads API Team 
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/ea0fc4d7-ddb4-4a43-9234-938283f0e7aen%40googlegroups.com.
  • Ge... Maxime Heurtevent
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
      • ... Maxime Heurtevent

Reply via email to