【发布时间】:2021-01-26 14:09:04
【问题描述】:
我已按照此tutorial 成功将模型部署到 AI Platform Predictions。现在,我想通过 HTTP 请求使用此模型进行预测。
按照@Ismail 的建议,我遵循了Method: projects.predict 文档。
我正在向 https://ml.googleapis.com/v1/projects/${PROJECT_ID}/models/${MODEL_NAME}:predict 发送一个 POST 请求,正文如下:
{
"instances": [
[51.0, 17.0, 6.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0]
]
}
数字是模型的输入。
我收到以下回复:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
我使用 RestMan chrome 扩展发送了 POST 请求。我希望能够使用 RestMan 进行预测。
我的问题是:如何验证我的 HTTP POST 请求?我应该在请求的标头中发送一些信息吗?
【问题讨论】:
-
如果您需要更多详细信息,请确保使用您的用例更新您的问题。我将在下面相应地更新我的答案
-
@Ismail 刚刚更新了它。谢谢!
-
您的 401 错误意味着您需要在运行请求之前进行身份验证 cloud.google.com/asset-inventory/docs/…
-
你在哪里运行请求? Cloud Shell,您的本地终端或客户端库。 cloud.google.com/docs/authentication/getting-started
-
@Ismail 我想这是我必须在请求的 HEADER 中传递的一些令牌
标签: machine-learning google-cloud-platform httprequest google-cloud-iam google-ai-platform