API 网关:TEST 按钮正常,Curl 500

API Gateway: ok on TEST button, 500 on Curl

我检查了所有配置,但仍然不明白为什么会发生...我的端点:

我在测试中的成功登录:

Execution log for request 24899adf-15c1-11e9-8131-9fdcec088245
Fri Jan 11 16:51:29 UTC 2019 : Starting execution for request: 24899adf-15c1-11e9-8131-9fdcec088245
Fri Jan 11 16:51:29 UTC 2019 : HTTP Method: POST, Resource Path: /
Fri Jan 11 16:51:29 UTC 2019 : Method request path: {}
Fri Jan 11 16:51:29 UTC 2019 : Method request query string: {}
Fri Jan 11 16:51:29 UTC 2019 : Method request headers: {}
Fri Jan 11 16:51:29 UTC 2019 : Method request body before transformations: 
Fri Jan 11 16:51:29 UTC 2019 : Endpoint request URI: https://polly.eu-central-1.amazonaws.com//v1/speech
Fri Jan 11 16:51:29 UTC 2019 : Endpoint request headers: {Authorization=***************************************************************************************************************************************************************************************************************************************************************************13f5d3, X-Amz-Date=20190111T165129Z, x-amzn-apigateway-api-id=ij6dyda1c4, Accept=application/json, User-Agent=AmazonAPIGateway_ij6dyda1c4, X-Amz-Security-Token=AgoGb3JpZ2luEK3//////////wEaCWV1LXdlc3QtMSKAAr1iooeT2rTwuuVQKVSAHDACPlRVsEAYoF7p4DnkjiUEYLS0eSMacs3+eLRt+PgpuKW7JvsZB435KWxYXcvWOYQ7KdHlHWX+M/S9tDVDDVBWJtftnv5WM26DYJHv5mHr/YHCefsW7VxRPqoB9uBea9hJ3ph2fN+NyLo/CeIrPgFuhkaex0gE4/j3DvLB+8Jqq3yFor9fLNFSI6hmNUUHBGcwmlDMr3j8QNht6OUZgg4TADmTIZhpo0V+ih3G0wzGm3/xm7fUKe7fZ//DJs6VTBBHahJ+2JdEXQ8dh8jEsRaJEb2n9cwDFlf1GLQiK56UGP+vmCorRwJjm6m6tveM/C4qigMIkv//////////ARAAGgwzMzYzMTkxMzM4MzgiDPuvnkrf52NaQ7BjZSreAhZw7AXI8UGATS35mtkqoKb1LIj4lyc7nTKgZXtim4KDYPHu1eypQwtnx9c93GxDy6dkz4GLvDayqWHy513K3hqsJlgXFEBtNBd6XA4rXY/t [TRUNCATED]
Fri Jan 11 16:51:29 UTC 2019 : Endpoint request body after transformations: {
   "OutputFormat": "ogg_vorbis",
   "Text": "string",
   "TextType": "text",
   "VoiceId": "Joanna"
}
Fri Jan 11 16:51:29 UTC 2019 : Sending request to https://polly.eu-central-1.amazonaws.com//v1/speech
Fri Jan 11 16:51:29 UTC 2019 : Received response. Integration latency: 164 ms
Fri Jan 11 16:51:29 UTC 2019 : Endpoint response body before transformations: OggSVd&�vorbis"V��OggSP��G�������������vorbisffmpegvorbis"BCV@B*�c�:�!���B�)�B�!�$C�:�5�cG�d�BɁАU@�WPrI-�s�W�q� �s� g�q   %�s�9�r�1�s�Wr)-�s�G�q��s�G�q��sm1��r�9�s� �Rr�5�s�gr%�s� g�q� �s�5��r�9�s�9�s�9�s�1�s�9�sn1�s�9�s�9�s�9�s 4d���(��(�
�@qG�K���$

Y�H��H��X�fi�&z�(��*��iʲ,˲�.�
HPQ�p
Yd`(��8��X��Y�����PG�M�$��<��<��<��<��<��<��<

Y �(dBCV@!C�R\
BCB�C����)�%c�S�A!|�=��{�АUa8���$!�b'Dq� !��$X�y�$݃B��{˹��{ 4d� �B!�B)��RH)��b� [TRUNCATED]
Fri Jan 11 16:51:29 UTC 2019 : Endpoint response headers: {Content-Type=audio/ogg, Date=Fri, 11 Jan 2019 16:51:29 GMT, x-amzn-RequestCharacters=6, x-amzn-RequestId=24a5395f-15c1-11e9-b3b5-f3a03497eaec, transfer-encoding=chunked, Connection=keep-alive}
Fri Jan 11 16:51:29 UTC 2019 : Method response body after transformations: OggSVd&�vorbis"V��OggSP��G�������������vorbisffmpegvorbis"BCV@B*�c�:�!���B�)�B�!�$C�:�5�cG�d�BɁАU@�WPrI-�s�W�q� �s� g�q  %�s�9�r�1�s�Wr)-�s�G�q��s�G�q��sm1��r�9�s� �Rr�5�s�gr%�s� g�q� �s�5��r�9�s�9�s�9�s�1�s�9�sn1�s�9�s�9�s�9�s 4d���(��(�
�@qG�K���$

Y�H��H��X�fi�&z�(��*��iʲ,˲�.�
HPQ�p
Yd`(��8��X��Y�����PG�M�$��<��<��<��<��<��<��<

Y �(dBCV@!C�R\
BCB�C����)�%c�S�A!|�=��{�АUa8���$!�b'Dq� !��$X�y�$݃B��{˹��{ 4d� �B!�B)��RH)��b�)� [TRUNCATED]
Fri Jan 11 16:51:29 UTC 2019 : Method response headers: {X-Amzn-Trace-Id=Root=1-5c38c991-0ada2ff083880c6182550904, Access-Control-Allow-Origin=*, Content-Type=audio/ogg}
Fri Jan 11 16:51:29 UTC 2019 : Successfully completed execution
Fri Jan 11 16:51:29 UTC 2019 : Method completed with status: 200

但是在curl:

curl -vd POST https://ij6dyda1c4.execute-api.eu-west-1.amazonaws.com/test
*   Trying 54.230.228.34...
* TCP_NODELAY set
* Connected to ij6dyda1c4.execute-api.eu-west-1.amazonaws.com (54.230.228.34) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=*.execute-api.eu-west-1.amazonaws.com
*  start date: Oct  9 00:00:00 2018 GMT
*  expire date: Oct  9 12:00:00 2019 GMT
*  subjectAltName: host "ij6dyda1c4.execute-api.eu-west-1.amazonaws.com" matched cert's "*.execute-api.eu-west-1.amazonaws.com"
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fa8ef800400)
> POST /test HTTP/2
> Host: ij6dyda1c4.execute-api.eu-west-1.amazonaws.com
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 4
> Content-Type: application/x-www-form-urlencoded
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
< HTTP/2 500 
< content-type: application/json
< content-length: 36
< date: Fri, 11 Jan 2019 16:46:16 GMT
< x-amzn-requestid: 69bba4ef-15c0-11e9-9029-471cfe507f1d
< x-amz-apigw-id: TWQ9zE4XDoEF2Cg=
< x-cache: Error from cloudfront
< via: 1.1 b3b1689b5de3293227c415784ed3c268.cloudfront.net (CloudFront)
< x-amz-cf-id: 5CmlH1PrYXKv_SP6QxHmH75WaovcewgZeWZcPuuZwDCsKHeQxfKd9Q==
< 
* Connection #0 to host ij6dyda1c4.execute-api.eu-west-1.amazonaws.com left intact
{"message": "Internal server error"}

而且我没有忘记部署:

我还看到记录了这 500 次点击:

在 CloudWatch 中我发现:Execution failed due to configuration error: Unable to transform response

大多数情况下这是由于 'Deploy API' 问题造成的。更改后忘记部署了吗?

您还可以查看这些阶段的部署历史记录。

为 API 网关启用二进制支持:EDIT1:

缺少的一部分是为响应启用直通。 查看如何从 lambda 或其他服务发送二进制响应。

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings-configure-with-console.html

另一方面,当大小超过 6 MB 时,您将遇到问题。小号就好

在您的请求中添加 header Accept: x-amazon-apigateway-binary-media-types.

但是我只能得到base64,当我设置Convert to binary (if needed)时也是500。