本文介绍了如何从AWS API Gateway传递标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从lambda函数传递附加键值对,与法律实验室.然后在API Gateway中,我在集成请求中设置了主体映射模板. (选中).

I'm passing the addition key-value pairs from lambda function, same as mention in aws labs. Then in API Gateway I have setup the body mapping templates in integration request. (Check this).

但是,当请求转到端点(PHP)时,我将无法获取任何数据.它是空数组print_r($_REQUEST);

But when request goes to the endpoint (PHP) then I'm unable to get any data. It is empty array print_r($_REQUEST);

我检查了cloudWatch,这是显示的内容.Endpoint request body after transformations:{ "userData" : "{"city":"USA","Name":"Sanket","id":3}" }

I checked cloudWatch this is what it is showing.Endpoint request body after transformations:{ "userData" : "{"city":"USA","Name":"Sanket","id":3}" }

其他信息-当我打印print_r($_REQUEST);时,它是一个空数组,但是当我打印$request->getContent();时,它显示了所有数据.

Additional info -When I print print_r($_REQUEST); then it is empty array but when I print $request->getContent(); it shows all the data.

更新-我此处的其他信息

推荐答案

您已经提到在集成请求中设置了主体映射模板.如果要集成响应,则应在集成响应中而不是在集成请求中进行设置.

You have mentioned that you have setup body mapping template in integration request. If you want to integrate a response then you should setup it in integration response, not in integration request.

这篇关于如何从AWS API Gateway传递标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 12:35
查看更多