每次使用以下代码为企业发布新评论时,我都会尝试订阅以接收通知。
private static final String topicName = "projects/myproject-12345/topics/business-review";
MyBusiness myBusiness = GMBFactory.getMyBusiness();
MyBusiness.Accounts.List accountsList = myBusiness.accounts().list();
ListAccountsResponse response = accountsList.execute();
List<Account> accounts = response.getAccounts();
for (Account account : accounts) {
Notifications notification = new Notifications().setName(topicName);
UpdateNotifications updateNotification = myBusiness.accounts().updateNotifications(account.getName() + "/notifications",
notification);
updateNotification.execute();
}
当我尝试执行代码时出现以下错误。
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Request contains an invalid argument.",
"reason" : "badRequest"
} ],
"message" : "Request contains an invalid argument.",
"status" : "INVALID_ARGUMENT"
}
有人可以告诉我我做错了什么吗?
- 编辑 -
MyBusiness myBusiness = GMBFactory.getMyBusiness();
MyBusiness.Accounts.List accountsList = myBusiness.accounts().list();
ListAccountsResponse response = accountsList.execute();
List<Account> accounts = response.getAccounts();
for (Account account : accounts) {
Notifications notification = new Notifications();
notification.setTopicName(topicName);
notification.setName("review");
UpdateNotifications updateNotification = myBusiness.accounts().updateNotifications(account.getName() + "/notifications",
notification);
updateNotification.execute();
}