how can i pass clientcustomerid dynamically

76 views
Skip to first unread message

vib...@whisskers.com

unread,
Nov 29, 2018, 2:37:51 AM11/29/18
to AdWords API and Google Ads API Forum
Hi 

I am using DotNet client library c# to download performance report and also other activity related to this for my customer account,  but when i want to do the same for my other customer

every time i have to got app.config and change ClientCustomerId(<add key="ClientCustomerId" value="xxx-xxx-xxxx"/>).

Can i pass it from c# code ? instead of app.config

Peter Oliquino (AdWords API Team)

unread,
Nov 29, 2018, 3:21:11 AM11/29/18
to AdWords API and Google Ads API Forum
Hi,

You can do this by using the Config property of the AdsUser object. You may refer to the "Configuring the Ads user instance at runtime" section of this guide as to how.

Best regards,
Peter
AdWords API Team

vib...@whisskers.com

unread,
Nov 29, 2018, 3:37:00 AM11/29/18
to AdWords API and Google Ads API Forum
Hi,

Thanks for the qiuck response

but after doing that i am facing the issue at below line

user.Config.clientCustomerId = "123-456-7890";
tried this one as well user.Config.ClientCustomerId = "123-456-7890";
key name in my app.config is  <add key="ClientCustomerId" value="123-456-7890"/>
please suggest me library reference if needed 

config.PNG

Zweitze

unread,
Nov 29, 2018, 5:41:15 AM11/29/18
to AdWords API and Google Ads API Forum
My method is to create a new AdWordsUser instance for that user. AdWordsUser has a constructor that takes a dictionary with key-value pairs - the values in that dictionary will override the values in app.config.

For instance:
            MyUser = new AdWordsUser(new Dictionary<string, string>
            {
                { "ClientCustomerId", MyCustomerId }
            });

Note: You can also pass other key-values pairs of setting you want to override. For instance,if you have batch-program working every night or so, you way also want to pass a RefreshToken so your program does not have to deal with logging in.

This is my preferred way. I know another way: after creating a service using your AdWordsUser, you can change its CientCustomerId. I can't remember now where, but some debugging will reveal where every service stores its ClientCustomerId. However, I don't know how to proceed with reports.

Hope this helps.

Peter Oliquino (AdWords API Team)

unread,
Nov 29, 2018, 6:13:09 AM11/29/18
to AdWords API and Google Ads API Forum
Hi,

Thank you for the assistance Zweitze. However, my apologies as I can not further assist you on this since the error is specific to the client library .NET. I would recommend that you post your concern in here instead as the .NET library owners are more equipped in assisting you on this.

Best regards,
Peter
AdWords API Team

vib...@whisskers.com

unread,
Nov 30, 2018, 12:27:49 AM11/30/18
to AdWords API and Google Ads API Forum

Thanks Zweitze, 

Solution works for me, i am new to googleadword so not aware whole design of library. it was not easy for me without  your help.

Thanks again
Reply all
Reply to author
Forward
0 new messages