我希望有人可以提供帮助,我已经让AWS Lambda在context.succeed或context.fail中返回了一些XML,除了一小部分外,一切都很好。我回应了XML,但因为标题仍然有Content-Type: application/json
而我正在谈论的Twilio服务器正在查看并拒绝它,即使正文实际上是有效的XML。
有没有办法覆盖标题?
非常感谢。
答案 0 :(得分:6)
如果您查看API网关控制台并选择相关方法,您应该会在右侧看到标题为方法响应的部分。如果您选择,您应该会看到各种响应代码,您可以添加一个或选择现有的响应代码,然后更改与该响应关联的Content-Type
。
答案 1 :(得分:1)
API网关目前不支持二进制数据。但是,您可以从Integration Layer(Lambda)返回base64编码数据。然后在API网关中,您可以使用集成响应将其解码为二进制文件:
WITH BASE AS (
SELECT EquipmentDetailsDataModel.EquipmentDetails.Equipment, EquipmentDetailsDataModel.EquipmentDetails.EqpGroup, EquipmentDetailsDataModel.EquipmentDetails.Fleet, EquipmentDetailsDataModel.EquipmentDetails.Site, SystemTableDataModel.ReportDate.[DATE]
FROM EquipmentDetailsDataModel.EquipmentDetails
CROSS JOIN SystemTableDataModel.ReportDate
WHERE
EquipmentDetailsDataModel.EquipmentDetails.BranchKey IN (@Branch)
AND EquipmentDetailsDataModel.EquipmentDetails.SiteKey IN (@Site)
AND EquipmentDetailsDataModel.EquipmentDetails.EqpClassKey IN (@EqpClass)
AND EquipmentDetailsDataModel.EquipmentDetails.EqpGroupKey IN (@EqpGroup)
AND EquipmentDetailsDataModel.EquipmentDetails.FleetKey IN (@Fleet)
AND EquipmentDetailsDataModel.EquipmentDetails.EquipmentKey IN (@Equipment)
AND SystemTableDataModel.ReportDate.[DATE] >= @StartDate
AND SystemTableDataModel.ReportDate.[DATE] < @EndDate)
SELECT
BASE.Site
, BASE.EqpGroup
, BASE.fleet
, BASE.equipment
, BASE.[DATE]
, PlanHrs
FROM BASE
LEFT JOIN
(SELECT EqpGroup, Equipment, [DATE], sum(datediff(minute,DayDownTime,DayUpTime))/60.0 as PlanHrs
FROM
(SELECT
EquipmentDetailsDataModel.EquipmentDetails.Equipment
,EquipmentDetailsDataModel.EquipmentDetails.EqpGroup
,BASE.[DATE]
,CASE WHEN BASE.[DATE] > StoppagesDataModel.StoppagesEvent.PlannedDownTime THEN BASE.[DATE] ELSE StoppagesDataModel.StoppagesEvent.PlannedDownTime END DayDownTime
,CASE WHEN BASE.[DATE] + 1 < StoppagesDataModel.StoppagesEvent.PlannedUpTime THEN BASE.[DATE] + 1 ELSE StoppagesDataModel.StoppagesEvent.PlannedUpTime END DayUpTime
FROM
StoppagesDataModel.StoppagesEvent
INNER JOIN EquipmentDetailsDataModel.EquipmentDetails
ON StoppagesDataModel.StoppagesEvent.EquipmentKey = EquipmentDetailsDataModel.EquipmentDetails.EquipmentKey
JOIN BASE ON StoppagesDataModel.StoppagesEvent.PlannedDownTime < BASE.[DATE] + 1 AND StoppagesDataModel.StoppagesEvent.PlannedUpTime > BASE.[DATE] AND BASE.Equipment = EquipmentDetailsDataModel.EquipmentDetails.Equipment
WHERE
EquipmentDetailsDataModel.EquipmentDetails.BranchKey IN (@Branch)
AND EquipmentDetailsDataModel.EquipmentDetails.SiteKey IN (@Site)
AND EquipmentDetailsDataModel.EquipmentDetails.EqpClassKey IN (@EqpClass)
AND EquipmentDetailsDataModel.EquipmentDetails.EqpGroupKey IN (@EqpGroup)
AND EquipmentDetailsDataModel.EquipmentDetails.FleetKey IN (@Fleet)
AND EquipmentDetailsDataModel.EquipmentDetails.EquipmentKey IN (@Equipment)
AND StoppagesDataModel.StoppagesEvent.PlannedDownTime >= @Now) T5
GROUP BY EqpGroup, Equipment, [DATE]) T6
ON (BASE.equipment=t6.equipment and BASE.[DATE] = t6.[DATE])
ORDER BY BASE.Equipment, BASE.[date]