0

My Spring Cloud Function(v3.1.6) based AWS Lambda function (without Lambda proxy integration) returns a list of data via API Gateway in the following format:

{
  "isBase64Encoded": false,
  "headers": {
    "id": "<some_id>",
    "contentType": "application/json",
    "timestamp": "1644307568294"
  },
  "body": "{\"resultList\":[{\"id\":\"1\",\"name\":\"item\",(...some other fields...)}]}",
  "statusCode": 200
}

My problem here is I want to return response.body in a JSON (ofc I've also created a Model schema) :

{
    "resultList": [
        { 
            "id": "1", "name": "item ",(...some other fields...)
        }
    ]
}

I've configured an application/json based Response Template Mapping to transform the response to the desired format:

$util.parseJson($input.json('$.body'))

which returned that I wanted (check the attached image): enter image description here

But when I call it via Postman, I've got this:

{
    "message": "Internal server error"
}

and in CloudWatch I can see this logs:

2022-02-08T08:56:00.688+01:00   (...) Endpoint response body before transformations: [Binary Data]
2022-02-08T08:56:00.694+01:00   (...) Execution failed due to configuration error: Unable to transform response

What can be the problem?

peter.szrnka
  • 43
  • 1
  • 10
  • Hey, I am wondering if you hit this issue - https://github.com/spring-cloud/spring-cloud-function/issues/787 which as you can see has already been addressed, but we do not have a corresponding release yet. Will have on on Feb 17th. Can you upgrade spring-cloud-function artifacts to 3.2.2-SNAPSHOT and validate so if there are still issues we have time to address it before next release? – Oleg Zhurakousky Feb 08 '22 at 09:44
  • Hi @OlegZhurakousky, thanks for the quick reply, I've tried, but I cannot see any difference. This time I'm not 100% sure the problem is with Spring Cloud Function, because it seems it returns a correct and valid JSON answer (see attached image) and if the problem is there, then the internal tester tool should return with the incorrect answer. On AWS side the $util.parseJson should parse the "body" : "{ \"result\" : [] }" and I don't know why it says it's a binary data despite I configured "Passthrough". – peter.szrnka Feb 08 '22 at 11:02

0 Answers0