Reputation: 121
I am using .NET client library for Google Adwords v201409.
I can create an account using ManagedCustomer + ManagedCustomerService.
The issue is that ManagedCustomer doesn't have an autoTagging field I can set.
I attempted to create a new account using ManagedCustomer, grab the CustomerId, and use Customer + CustomerService, as Customer has the autoTagging field, but this didn't work (USER_PERMISSION_DENIED). I'm assuming because the CustomerId generated when making the new account isn't associated with an account with the correct permissions to alter data.
So how can I, through the API, create a new account and set the autoTagging value to TRUE or create a new account and then update it's autoTagging value to TRUE?
Upvotes: 2
Views: 535
Reputation: 121
Ok. So I solved the problem.
When I want to update autoTagging on the newly created ManagedCustomer, I instantiate another AdwordsUser and change its ClientCustomerId to be the newly created ManagedCustomer customerId. Then I use Customer + CustomerService to update.
I followed the code examples provided by Google and this is how I instantiate an AdwordsUser:
AdWordsUser adwordsUser = new AdWordsUser();
AdWordsAppConfig adwordsConfig = (AdWordsAppConfig)adwordsUser.Config;
adwordsConfig.ClientCustomerId = ENTER CUSTOMERID HERE;
This way, the ClientId/ClientSecret/OAuthToken are there for API calls but the CustomerId is now the CustomerId of the newly created ManagedCustomer. So when we change the autoTagging field for Customer and update it, that ManagedCustomers autoTagging value is updated like we want.
This is the code where the autoTagging field is updated:
private void updateAdwordsCustomer(AdWordsUser adwordsUser)
{
CustomerService CustSer = (CustomerService)adwordsUser.GetService(
AdWordsService.v201409.CustomerService);
Customer customer = new Customer();
customer.autoTaggingEnabled = true;
var s = CustSer.mutate(customer);
}
Upvotes: 2