Cant change non proxy status code [apig]

hai i thing im kinda lost here, so i make new thread here…
i use v1.0.3, i dont know this is bug or my silly mistake again but this is it…

i work with json, send json to my lambda function

if i use proxy-lambda it will always return error and i dont know how to get value from json… i already use JSON.parse and JSON.stringify and still cant fix my problem…
always stack on

Unexpected token u at Object.parse (native)
or json value is > undefined

if i use lambda intregration i can take the value from json request but the costum status code not work(for me here is [409]…
but but the default value for status code is totaly fine[201]…
.yml file for intregration is like this

integration: lambda
response:
headers:
Content-Type: “‘text/html’”
template: $input.path(‘$’)
statusCodes:
201:
pattern: ‘’ # Default response method
409:
pattern: ‘.“statusCode”:409,.’ # JSON response
template:
application/json: $input.path(“$.errorMessage”) # JSON return object
application/xml: $input.path(“$.body.errorMessage”) # XML return object
headers:
Content-Type: “‘application/json+hal’”

response =
{
statusCode : 409,
body: {
errorMessage : “Mobile Number is not define or not on our Database”
}
}

is there some one face problem like me?

Your serverless.yml file should look something like this

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: post
          integration: lambda
          response:
            headers:
              Content-Type: "'application/json'"
            template: $input.body
            statusCodes:
              201:
                pattern: ''
              409:
                pattern: '.*"statusCode":409.*'
                template: $input.path('$.errorMessage')

Your default response will now be 201 instead of 200. All you need to do to get a 201 response is return a success.

'use strict';

module.exports.hello = (event, context, callback) => {
  callback(null, event.body);
};

To have it return a 409 error you need you need to callback with an error object

'use strict';

module.exports.hello = (event, context, callback) => {
  let result = {
    "statusCode": 409,
    "error": "Something went wrong"
  }
  callback(JSON.stringify(result), null);
};

Sorry to bring this back to life. But I’m new to serverless and AWS lambda with API Gateway. So I having a little trouble to return a 404 status code.

I have this in the serverless.yml for the get service

    -http
        response:
          headers:
            Content-Type: "'application/json'"
          template: $input.path('$')
          statusCodes:
            200:
              pattern: ''
            404:
              pattern: '.*"statusCode":404,.*'

and my lambda function returns

callback( null, JSON.stringify({ statusCode: 404, body: { message: "Resource not found" } }) );

I get a return with status 200. and the json in the body. In serverless-offline I get a status 200 and the json in the body. In lambda test I got
http 500
{
“message”: “Internal server error”
}

anyone can explain it to me why?

I tried setting the callback in the error callback ( JSON.stringify… , null ); with no luck too

You JSON.stringify() the body content and return the rest as a Javascript object.

callback(null, {
  statusCode: 404,
  body: JSON.stringify({ message: "Resource not found" })
});

I got help in gitter.
The problem was integration type set to lambda.
So I removed from serverless.yml integration and response. Using the default integration lambda-proxy.
And the body don’t need to be a string. At lest I’m passing a JSON object to it and it’s working great.

Thanks anyway.