Home > Software design >  GetAndroidConfig using firebase management service C# .NET returning Google.GoogleApiException: Para
GetAndroidConfig using firebase management service C# .NET returning Google.GoogleApiException: Para

Time:11-19

After creating a web app config in firebase using the c# library, I wanted to get the configuration file, but I am getting error :- Google.GoogleApiException: Parameter validation failed for "parent" : The value did not match the regular expression ^projects/[^/] $ ..... as shown below , how do I fix this issue?

     public static WebAppConfig GetWebAppConfig()
   {
        var listWeb = _firebaseManagementService.Projects.WebApps.List("projects/"   CloudManager.ProjectId   "/webApps").Execute();
        return _firebaseManagementService.Projects.WebApps.GetConfig("projects/-/webApps/"   listWeb.Apps[0].AppId   "/config").Execute();
   }

Edited -> The error that displays in my terminal is as shown below

Unhandled exception. The service firebase has thrown an exception. No HttpStatusCode was specified. No error details were specified. Google.GoogleApiException: Parameter validation failed for "parent" : The value did not match the regular expression ^projects/[^/] $ at Google.Apis.Requests.ClientServiceRequest1.AddParameters(RequestBuilder requestBuilder, ParameterCollection inputParameters) at Google.Apis.Requests.ClientServiceRequest1.CreateBuilder() at Google.Apis.Requests.ClientServiceRequest1.CreateRequest(Nullable1 overrideGZipEnabled) at Google.Apis.Requests.ClientServiceRequest1.ExecuteUnparsedAsync(CancellationToken cancellationToken) at Google.Apis.Requests.ClientServiceRequest1.Execute()

CodePudding user response:

Your config path in the second call seems to be malformed.

return _firebaseManagementService.Projects.WebApps.GetConfig("projects/-/webApps/" listWeb.Apps[0].AppId "/config").Execute();

Let's imagine that listWeb.Apps[0].AppId contains "foo-app-id". That would result in the path parameter for the GetConfig call to be set as "projects/-/webApps/foo-app-id/config". This doesn't seem like a valid path for Google Cloud Platform (the dash after "projects/" is what's off).

I'd guess you want to use your CloudManager.ProjectId variable value in this path too:

return _firebaseManagementService.Projects.WebApps.GetConfig("projects/" CloudManager.ProjectId "/webApps/" listWeb.Apps[0].AppId "/config").Execute();

CodePudding user response:

The problem was on this line,

var listWeb = _firebaseManagementService.Projects.WebApps.List("projects/"   CloudManager.ProjectId   "/webApps").Execute();

And removing /webApps resolved the issue

var listWeb = _firebaseManagementService.Projects.WebApps.List("projects/"   CloudManager.ProjectId).Execute();
  • Related