【问题标题】:Cloud AutoML API has not been used in project 618104708054 before or it is disabledCloud AutoML API 之前未在项目 618104708054 中使用或已禁用
【发布时间】:2019-02-06 14:03:16
【问题描述】:

我正在尝试构建一个 .NET 小应用程序,以使用我在 AutoML 上试用过的模型来预测图像。

但我收到此错误:

Cloud AutoML API 之前未在项目 618104708054 中使用或 它被禁用。通过访问启用它 https://console.developers.google.com/apis/api/automl.googleapis.com/overview?project=618104708054 然后重试。如果您最近启用了此 API,请等待几分钟 传播到我们的系统并重试的操作

首先 - 这不是我正在使用的项目。 第二 - 如果我使用我的真实项目 ID 访问链接 - 它告诉我 api 运行良好。

我的代码如下所示:

public static string SendPOST(string url, string json)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "POST";
            httpWebRequest.Headers.Add("Authorization", "Bearer GOOGLE_CLOUD_TOKEN");
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                //var res = new JavaScriptSerializer().Deserialize<Response>(result);
                //return res;
                return result;
            }           
        }

我会感谢你的帮助, 谢谢。

【问题讨论】:

  • 我整天都在为同样的错误而苦苦挣扎。不幸的是我还没有解决它。
  • 嗨,我留下了答案

标签: automl google-cloud-automl


【解决方案1】:

我终于成功了,唯一的问题是我需要使用 Web 控制台创建一个服务帐户:

https://console.cloud.google.com/projectselector/iam-admin/serviceaccounts?supportedpurview=project&project=&folder=&organizationId=

然后下载 json 密钥并通过我的 PC 上的 gcloud 命令推送它 -

gcloud auth activate-service-account --key-file="[/PATH/TO/KEY/FILE.json]

我在这篇文章中找到了解决方案: "(403) Forbidden" when trying to send an image to my custom AutoML model via the REST API

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-13
    • 2023-03-13
    • 2018-10-18
    • 2023-02-09
    • 2019-02-08
    • 1970-01-01
    • 1970-01-01
    • 2020-02-18
    相关资源
    最近更新 更多