如何执行aws apigateway post方法表单客户端?

时间:2018-02-11 08:01:11

标签: amazon-web-services http-post aws-api-gateway

我创建了一个既有get又有post方法的API网关,两者都有相同的参数,并且会执行相同的lambda函数。我的get方法url是; https://zfd17ebjag.execute-api.ap-south-1.amazonaws.com/stage/cons?name=testname

和我的帖子方法网址是;

https://zfd17ebjag.execute-api.ap-south-1.amazonaws.com/stage2/cons?name=testname

当我调用get url时,它成功执行..

但是当我打电话给一个帖子网址时,它显示以下错误..

{"message":"Missing Authentication Token"}

是否可以通过其他方式调用post方法?

1 个答案:

答案 0 :(得分:0)

调用GET和POST URL的方式不同。 GET用于从指定资源请求数据。 POST用于将数据发送到服务器以创建/更新资源。

在您的情况下,您似乎已启用了方法请求中所需的API密钥。

enter image description here

enter image description here

现在,要么关闭所需的API密钥,要么必须在调用POST方法URL时在标头中发送API密钥。 假设XXXXXXXXX是API密钥,内容类型是application / json。您可以使用curl调用POST网址。参见下面的命令。

curl -X POST -H "x-api-key: XXXXXXXXX" -H "Content-Type: application/json" -d '{"name":"testname"}' https://zfd17ebjag.execute-api.ap-south-1.amazonaws.com/stage2/cons

您还可以通过邮递员呼叫POST网址。 查看屏幕截图。 enter image description here 设置柱体。 enter image description here

相关问题