How to Add Account/Campaign-Level Shared Set via API, and Issues with Adding Campaign-Level Shared Set

51 views
Skip to first unread message

Lóránd Balog

unread,
Oct 14, 2024, 11:42:25 AM10/14/24
to Google Ads API and AdWords API Forum

Hi,

I'm trying to add a shared exclusion list (shared set) at the account level programmatically using the Google Ads API, but I haven't found a direct way to do this. Could you please provide guidance on how to add a shared set at the account level from code?

Additionally, I have a shared set created at the MCC (root account) level, and when I try to apply it to a campaign, I get the following error both through the UI and the API:

Error from the UI: EntityNotFound.INVALID_ID – "SharedSet not found or not allowed to be attached to a campaign"
Error from the API: "Resource not found" or similar error.

I've tried both scenarios:

  1. When the shared set is shared with the sub-account.
  2. When the shared set is not shared with the sub-account.

In both cases, I encounter errors when trying to add the shared set to a campaign.

Questions:

  • What is the correct way to handle shared sets when trying to apply them to a campaign (whether shared or not)?
  • How can I programmatically add a shared set at the account level via the API?
  • What could be causing the "resource not found" issue in both the API and UI when attempting to apply the shared set to a campaign?

Any help or clarification on the correct process for handling shared sets at the account and campaign levels via the API would be appreciated!

Google Ads API Forum Advisor

unread,
Oct 15, 2024, 7:48:16 AM10/15/24
to lor...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

Based on the information provided, I understand that you are trying to programmatically add a shared exclusion list (shared set) at the account level using the Google Ads API, but haven't found a direct method to do so and are seeking guidance on how to achieve this through code. Can you confirm the SharedSetType that you are trying to create? I would recommend you to kindly refer to the Create And Attach Shared Keyword Set guide as it explains clearly on how to create a shared set and attach it to the campaign using the Google Ads API. We have tried this approach in creating the shared set types as 'NEGATIVE_KEYWORDS' and were able to succeed in attaching the shared set to the campaign. You can use the customers.sharedSets method for creating the shared set and customers.campaignSharedSets method for attaching the shared set to the campaign. However, I am attaching the sample request and response logs for your reference. 
Shared set Creation:
=====================

Request Body:
============

POST https://googleads.googleapis.com/v17/customers/{customerId}/sharedSets:mutate?key=[YOUR_API_KEY] HTTP/1.1

developer-token: **********************
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json

{
  "operations": [
    {
      "create": {
        "name": "shared set in client account",
        "type": "NEGATIVE_KEYWORDS"
      }
    }
  ]
}

Response:
==========

HTTP/1.1 200 
cache-control: private
content-encoding: gzip
content-length: 109
content-type: application/json; charset=UTF-8
date: Tue, 15 Oct 2024 08:22:32 GMT
server: ESF
vary: Origin, X-Origin, Referer

{
  "results": [
    {
      "resourceName": "customers/{customerId}/sharedSets/{shared_set_id}"
    }
  ]
}

Attaching the shared set to the campaign:
===================================

Request Body:
=============

POST https://googleads.googleapis.com/v17/customers/{customerId}/campaignSharedSets:mutate?key=[YOUR_API_KEY] HTTP/1.1

developer-token: **********************
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json

{
  "operations": [
    {
      "create": {
        "campaign": "customers/{customerId}/campaigns/{campaignId}",
        "sharedSet": "customers/{customerId}/sharedSets/{shared_set_id}"
      }
    }
  ]
}

Response:
=========

HTTP/1.1 200 
cache-control: private
content-encoding: gzip
content-length: 129
content-type: application/json; charset=UTF-8
date: Tue, 15 Oct 2024 08:38:45 GMT
server: ESF
vary: Origin, X-Origin, Referer

{
  "results": [
    {
      "resourceName": "customers/{customerId}/campaignSharedSets/{campaignId}~{shared_set_id}"
    }
  ]
}

Similarly, we created a shared set at the MCC level using the Google Ads API and attempted to link it to a campaign, but encountered a RESOURCE_NOT_FOUND error. We later understood that since campaigns cannot be created at the MCC account level, the shared set cannot be attached to client-level campaigns. However, we were able to apply the MCC level shared sets 'NEGATIVE_KEYWORDS' to the client level campaigns without any issues from the Google Ads UI. 

In order to investigate your issue further, kindly provide us with the complete API logs (request and response logs with request-id and request header) generated at your end and uncropped UI screenshot of the Google Ads account where you are facing the issue.

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, .Net, PHP, Python, Ruby or Perl 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.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vGePS:ref" (ADR-00271703)

Thanks,
 
Google Logo Google Ads API Team


Lóránd Balog

unread,
Nov 4, 2024, 5:17:31 PM11/4/24
to Google Ads API and AdWords API Forum

Hi,

We currently have a Placement Exclusion List created at the Root account level through the UI. Our goal is to attach this shared set to a regular account (sub-account) under an MCC account, either at the account or campaign level via code. When attempting to add it at the campaign level, we receive a "resource not found" error from the code. Additionally, we haven’t found any examples in .NET for attaching the shared set at the account level.

In the Google Ads UI, we can share the shared set with sub-accounts directly through the sub-account settings. However, we are unsure how to replicate this programmatically using the Google Ads API. Could you provide guidance or examples for adding a shared set at the account level, similar to the UI process?

Thank you for your assistance!

Google Ads API Forum Advisor

unread,
Nov 5, 2024, 3:06:58 PM11/5/24
to lor...@gmail.com, adwor...@googlegroups.com
Hi,

Could you please provide us with the uncropped UI screenshot where you can share the shared set with sub-accounts directly and also the complete API logs (request and response with request-id and request header) generated at your end for the 'resource not found' error. This would help us investigate this issue further.
Reply all
Reply to author
Forward
0 new messages