curl --data_raw doesn't work. neither does -d

46 views
Skip to first unread message

David Scott

unread,
Aug 26, 2020, 12:02:06 PM8/26/20
to AdWords API and Google Ads API Forum
Request:

--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {authorization_code}' \
--header 'developer-token: {developer_token}' \
--header 'login-customer-id: {login-customer-id}' \
--header 'resolveWithFullResponse: true' \
--header 'x-goog-api-client=gl-java/1.8.0_181-google-v7 gapic/ gax/1.35.0 grpc/1.16.1' \


--data-raw '{
  "operations": [
    {
      "updateMask": "campaign.status",
      "update": {
        "resourceName": "customers/{customer_id}/campaigns/{campaign_id1}",
        "status": "PAUSED"
      }
    },
    {
      "updateMask": "campaign.status",
      "update": {
        "resourceName": "customers/{customer_id}/campaigns/{campaign_id2}",
        "status": "PAUSED"
      }
    }
  ]
}'

Response:

./pause_campaign.sh
{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "errors": [
          {
            "errorCode": {
              "fieldError": "REQUIRED_NONEMPTY_LIST"
            },
            "message": "The required repeated field was empty.",
            "location": {
              "fieldPathElements": [
                {
                  "fieldName": "operations"
                }
              ]
            }
          }
        ]
      }
    ]
  }
}
./pause_campaign.sh: line 27: --data-raw: command not found

How am I supposed to pass data in curl???

David Scott

unread,
Aug 26, 2020, 12:55:45 PM8/26/20
to AdWords API and Google Ads API Forum

I figured it out:

There can be no spaces between the --header and --data AND campaign.status needs to be just status

David

Here is the code that works:

curl --request POST 'https://googleads.googleapis.com/v4/customers/{customer_id}/campaigns:mutate' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {authorization_code}' \
--header 'developer-token: {developer_token}' \
--header 'login-customer-id: {login-customer-id}' \
--header 'resolveWithFullResponse: true' \
--header 'x-goog-api-client=gl-java/1.8.0_181-google-v7 gapic/ gax/1.35.0 grpc/1.16.1' \
--data-raw '{
  "operations": [
    {

      "updateMask": "status",


      "update": {
        "resourceName": "customers/{customer_id}/campaigns/{campaign_id1}",
        "status": "PAUSED"
      }
    },
    {

      "updateMask": "status",


      "update": {
        "resourceName": "customers/{customer_id}/campaigns/{campaign_id2}",
        "status": "PAUSED"
      }
    }
  ]
}'

Reply all
Reply to author
Forward
0 new messages