我尝试运行示例CURL来访问我设置的Amazon AWS api-gateway。 我用xxx替换了下面的任何私有值。
curl -X POST https://xxx.execute-api.eu-west-1.amazonaws.com/dev/screenshots?url=http://google.com/ -H "x-api-key: xxx" { "hash": "6ab016b2dad7ba49a992ba0213a91cf8", "key": "6ab016b2dad7ba49a992ba0213a91cf8/original.png", "bucket": "mybucketname", "url": "http://xxx.cloudfront.net/6ab016b2dad7ba49a992ba0213a91cf8/original.png"}
以此为例建模:https://serverless.com/blog/building-a-serverless-screenshot-service-with-lambda/
当我跑步时,我得到:
{"message":"Forbidden"}curl: (3) <url> malformed
curl: (6) Couldn't resolve host 'hash'
curl: (6) Couldn't resolve host '6ab016b2dad7ba49a992ba0213a91cf8,key'
curl: (6) Couldn't resolve host '6ab016b2dad7ba49a992ba0213a91cf8'
curl: (6) Couldn't resolve host 'mybucketname,url'
curl: (3) [globbing] unmatched close brace/bracket in column 83
我还尝试对google.com周围的斜杠进行网址编码,但出现了相同的错误。 是因为命令长度是> 255,如果是这样,如何克服这个?我在Windows 10中运行。
答案 0 :(得分:0)
最后的hash / key / bucket / url位(包括大括号和标点符号)应作为curl的输入提供,而不是curl命令行。您引用的文档将其显示为终端上的后续行,而不是所有行都在同一行。
答案 1 :(得分:0)
@randomir指出其他字段正在返回,而不是传递给服务。另外,我不得不在-H值周围加上大括号来传递{&#34;消息&#34;:&#34;禁止&#34;}错误。
curl -X POST -H {"x-api-key: xxxxxxxx"} https://xxx.execute-api.eu-west-1.amazonaws.com/dev/screenshots?url=http://google.com/