amazon-web-services - 我正在尝试 curl GET 请求

标签 amazon-web-services curl aws-api-gateway

我对 openstack 和软件开发很陌生,但这里是。
我正在尝试通过 AWS Api Gateway curl GET 请求。

curl 看起来像这样:

curl -H "Accept: application/json" -H "Content-Type: application/json" -i GET -d 'name=Claus&username=gettest&password=test' https://xy8fbbpvak.execute-api.eu-west-1.amazonaws.com/prod/adduser

但它给了我这个回应:
curl: (6) Could not resolve host: GET
HTTP/1.1 403 Forbidden
Content-Type: application/json
Content-Length: 43
Connection: keep-alive
Date: Tue, 18 Jul 2017 06:10:08 GMT
x-amzn-RequestId: c049f3e5-6b7f-11e7-a380-d966a8908f27
x-amzn-ErrorType: MissingAuthenticationTokenException
X-Cache: Error from cloudfront
Via: 1.1 dc81da318a4ae20e51ccfd9463219596.cloudfront.net (CloudFront)
X-Amz-Cf-Id: BI3LX_cwBic2EtCleIHd6yT0B1p4GRoqEbqx85L1nO2UUafPKXC2iQ==

{"message":"Missing Authentication Token"}

AWS API Gateway 中的方法不需要授权或 token 。

我真的不确定我做错了什么?如果您需要更多信息,请告诉我。

最佳答案

留言{"message":"Missing Authentication Token"}不一定意味着它需要授权或 token ,但如果您请求不存在的 URL,您会收到相同的错误

您需要确保使用正确的 HTTP 方法和有效资源的资源路径。

在您的示例中,您使用的是 GET并且 Action 是prod/adduser ,这对我来说听起来不太好,addUser 通常会在 PUT 上创建或 POST当您设计 API 时。

还要确保部署您的 API 更改,当您从 API 网关进行测试时,它是一个暂存区域但未部署

关于amazon-web-services - 我正在尝试 curl GET 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45159173/

相关文章:

amazon-web-services - 如何将授权/api key 附加到 sam cli 生成的 api?

amazon-web-services - 创建与子类型 SQS-SendMessage 的 ApiGatewayV2 HTTP API 集成失败并返回 400

amazon-web-services - 如何在 AWS API Gateway 中生成 Set-Cookie 集成响应 header ?

amazon-web-services - 将 lambda 目标角色添加到 Cloudformation 中的 AWS Eventbridge 规则失败

amazon-web-services - 代码管道 : CodeDeploy reports "BundleType must be either YAML or JSON"

amazon-web-services - 我只需要为 3 个云提供商 AWS、GCP、阿里巴巴创建集中式 DNS/LDAP

rest - 从 Go Code 使用 API 时出现 401 错误,而 cURL 运行良好

java - 什么等同于 java 中的以下 curl 命令

amazon-web-services - 如何使用 HTTP 在 AWS EC2 实例上公开端口 8888

ssl - 直接从 Apache Ant 调用时,为什么带有 SSL 的 cURL 不起作用