Hi Dannison, Referring to the GetCampaigns.cs, I've worked out the code below. I like the flexibility of using GoogleAdsService queries - https://developers.google.com/google-ads/api/docs/query/overview, which is more relevant to my project than using UserListService.
GoogleAdsServiceClient googleAdsService = _adsClient.GetService(Services.V1.GoogleAdsService); string query = $@"SELECT user_list.id, user_list.name, user_list.membership_status FROM user_list WHERE user_list.name = '{audienceName}' ORDER BY user_list.id DESC "; SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { PageSize = PAGE_SIZE, Query = query, CustomerId = customerId.ToString() }; PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse = googleAdsService.Search(request); return (long)searchPagedResponse.FirstOrDefault()?.UserList.Id; Thanks very much for your help. Best Regards Sarah On Wednesday, March 20, 2019 at 6:32:25 AM UTC, googleadsapi-forumadvisor wrote: > > Hi Sarah, > > You can retrieve the UserList Ids by using the UserListService.GetUserList > <https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v1.services#userlistservice> > > and get UserList.id > <https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v1.resources#google.ads.googleads.v1.resources.UserList>. > > My apologies as there are no sample codes available right now that I can > provide. However, you may refer to the GetCampaigns.cs > <https://github.com/googleads/google-ads-dotnet/blob/master/examples/BasicOperations/GetCampaigns.cs> > > guide on how to use the get operation. > > Regards, > Dannison > Google Ads API Team > > > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > Also find us on our blog and discussion group: > http://googleadsdeveloper.blogspot.com/search/label/adwords_api > https://developers.google.com/adwords/api/community/ > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > > Was your question answered? Please rate your experience with us by taking > a short survey. > If not -- reply to this email and tell us what else we can do to help. > > Take Survey > <https://support.google.com/google-ads/contact/survey_transactional?caseid=0-2177000025703&hl=en&ctx=1> > > Also find us on our blog and discussion group: > http://googleadsdeveloper.blogspot.com/search/label/adwords_api > https://developers.google.com/adwords/api/community/ > On 03/19/19 23:40:51 sara...@apteco.com <javascript:> wrote: > > Hi > > public long LookAudienceIdUsingName(string name) > { > AdwordsUserListService userListService = > (AdwordsUserListService)_user.GetService( > AdWordsService.v201809.AdwordsUserListService); > > string query = $"SELECT Id, Name, Status, AccountUserListStatus > Where Name = '{name}' ORDER BY Id Desc"; > int offset = 0; > int pageSize = 1; > UserListPage page = new UserListPage(); > > string queryWithPaging = $"{query} LIMIT {offset}, {pageSize}"; > page = userListService.query(queryWithPaging); > > foreach (UserList userList in page.entries) > return page.entries[0].id; > > return 0; > } > > The above is my C# code to get an audience Id calling AdWords API - this > works fine no problem. > > I'm now migrating our integration to Google Ads API. Can you please > provide a sample code that do the same as the above ? I couldn't find one. > > Thanks. > Sarah > > -- > -- > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > 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 > "AdWords API and Google Ads API Forum" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to adwords-api+unsubscr...@googlegroups.com. > Visit this group at https://groups.google.com/group/adwords-api. > To view this discussion on the web visit > https://groups.google.com/d/msgid/adwords-api/a4dcfac3-42dc-4a42-9fc5-86b744b44390%40googlegroups.com > > <https://groups.google.com/d/msgid/adwords-api/a4dcfac3-42dc-4a42-9fc5-86b744b44390%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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 "AdWords API and Google Ads API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. Visit this group at https://groups.google.com/group/adwords-api. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/fd19fda4-30e0-4471-83c9-62fe57ad487f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.