Search code examples
c#.netgoogle-my-business-api

GMB API - Unable to Get/Updated Google Business Account Pub/Sub Notification Settings


I am trying to use Google My Business API C# Client Library: https://developers.google.com/my-business/samples/ in order to get real-time notifications for Location and Reviews. I have followed the steps provided at: https://developers.google.com/my-business/content/notification-setup#get_started . But I am stuck at point 5) Account.updateNotifications.

I am receiving this error: "{Parameter validation failed for \"name\"}"

I am able to use the same "name" parameter to fetch the Account, Locations, Review etc. successfully, but it's not working with Notifications. I am attaching the code below.

GMBServiceInit();
string name = "accounts/1234567890132456"
var notification = new Notifications
{
    TopicName = "projects/gmbproject/topics/notification_topic",
    NotificationTypes = new List<string>
    {
        "NEW_REVIEW",
    }
};

//Get Notifications Settings
var response = await GMBService.Accounts.GetNotifications(name).ExecuteAsync();

//Update Notifications Settings
var updateNotificationRequest = GMBService.Accounts.UpdateNotifications(notification, name);
var updateNotificationReponse = await updateNotificationRequest.ExecuteAsync();

If someone had this issue, please help me to figure out this issue. Thanks!


Solution

  • Found the solution.

    I am using the name as:

    string name = "accounts/1234567890132456"
    

    I should be using:

    string name = "accounts/1234567890132456/notifications"