Equivalent of add_crm_based_user_list.py example in Google Ads API v0 via REST API?

92 views
Skip to first unread message

Jason Hsieh

unread,
Feb 25, 2019, 11:28:28 AM2/25/19
to AdWords API and Google Ads API Forum
Since I use Node.js and there is no Google Ads API client library in Node.js so I choose to use REST API.

Following this Call Structure document, I can create userList via REST API via HTTP POST to https://googleads.googleapis.com/v0/customers/31259999xx/userLists:mutate with auth info on headers and below body data

{
  "operations": [
    {
      "create": {
        "readOnly": false,
        "name": "jason-test-audience-name-3",
        "description": "test",
        "membershipStatus": "OPEN",
        "membershipLifeSpan": "540",
        "sizeForDisplay": "0",
        "sizeRangeForDisplay": "LESS_THAN_FIVE_HUNDRED",
        "sizeForSearch": "0",
        "sizeRangeForSearch": "LESS_THAN_FIVE_HUNDRED",
        "type": "CRM_BASED",
        "accessReason": "OWNED",
        "accountUserListStatus": "ENABLED",
        "eligibleForSearch": false,
        "eligibleForDisplay": true,
        "crmBasedUserList": {
          "appId": "com.garena.game.kgvn",
          "uploadKeyType": "MOBILE_ADVERTISING_ID",
          "dataSourceType": "FIRST_PARTY"
        }
      }
    }
  ]
}

Enter code here...

I can received correct response as below
{
    "results": [
        {
            "resourceName": "customers/3125820670/userLists/769964xxx"
        }
    ]
}

But I cannot find any fields according to this in the request body to upload my *.csv files or array of ids so I ended up create a audience list without csv file.


By tracing back to AdWords API python client library's example code : 


I realized it might need to call different API.


result = user_list_service.mutate(operations)

one for updating members in the user list

response = user_list_service.mutateMembers([mutate_members_operation])


How can I do the equivalent of add_crm_based_user_list.py example do in the Google Ads API v0 via REST API?

rest-ad-user-list.png
web-gui-ad-user-list.png

Afonso Praça

unread,
Feb 25, 2019, 2:50:11 PM2/25/19
to AdWords API and Google Ads API Forum
Hello 
謝子皓

How did you manage to authenticate using just REST? I'm using Node.js too and I am finding issues to do that.

Best,

googleadsapi...@google.com

unread,
Feb 25, 2019, 5:37:18 PM2/25/19
to AdWords API and Google Ads API Forum
Hello Jason, 

The mutate and mutateMembers are two different operations as listed in the code sample. You will first need to create a user list which will include the user list fields as listed here from L38 - L45. Once the user list is added you will need to perform the mutateMembers operation to add users to the list. It looks like you're combining them in a single operation. you will need to create an Info object (e.g., CrmBasedUserListInfo) and set it to the UserList object via the setCrmBasedUserList() method. You can then use the mutateUserLists operation to add the members to the list. 

CrmBasedUserListInfo userList = CrmBasedUserListInfo.newBuilder()
.setUploadKeyType(CustomerMatchUploadKeyType.CONTACT_INFO)
.build();

UserList newUserList = UserList.newBuilder()
.setName(StringValue.of("Oler user list test 1"))
.setCrmBasedUserList(userList)
.build();

UserListOperation userListOperation = UserListOperation.newBuilder()
.setCreate(newUserList)
.build();

It is similar to the AddExpandedTextAds example. 

@Afonso: I see that your concern has been addressed on this thread. Please continue the discussion on that thread to avoid duplicates.

Thanks,
Bharani, 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

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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+unsubscribe@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/1f4d75b3-29aa-48d9-a79f-72a67d8ce672%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Hsieh

unread,
Feb 26, 2019, 8:25:15 AM2/26/19
to AdWords API and Google Ads API Forum
Hi Bharani,

Thanks for your explanation.

The code you metioned is Google Adwords API, I choose to not use it because of I'm using Node.js and Google Adwords API didn't provide REST API, it's hard to use it from other languages without offical support SDK.

I think Google Ad API v0 has not support the feature to mutateUserList according to this source code, there is no corresponding file in  google.ads.googleads.v0.common.CrmBasedUserListInfo (https://github.com/googleapis/googleapis/tree/master/google/ads/googleads/v0/common).

thanks anyway, i will postpone this feature until CrmBasedUserListInfo implement.

Jason Hsieh

unread,
Feb 26, 2019, 5:04:29 PM2/26/19
to AdWords API and Google Ads API Forum
Hi,

I have not implemented node.js auth yet, currently i'm using python auth sample to get token from my dev ad account and paste to my HTTP auth header for using REST API.

googleadsapi...@google.com

unread,
Feb 27, 2019, 2:03:48 PM2/27/19
to appl...@gmail.com, AdWords API and Google Ads API Forum
Hello, 

The node.js library that you're using is a third-party library and we will not be able to pass a comment on this. Could you please elaborate if you need any additional assistance?

Thanks,
Bharani, Google Ads API Team

googleadsapi...@google.com

unread,
Mar 25, 2019, 3:33:11 PM3/25/19
to AdWords API and Google Ads API Forum
Hello, 

As a correction to my previous response, MutateMembers operation is not yet supported through the Google Ads API. If you are looking to update the user list and not the members in the user list, you can use the MutateUserLists to perform the update operation. Please keep an eye on our blog for future updates.

Thanks,
Bharani, 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.

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Reply all
Reply to author
Forward
0 new messages