"Unsupported Media Type" using serverless offline
Asked Answered
T

1

2

I'm working on a small serverless offline assignment and I got error Unsupported Media Type when tried to invoke one lambda function in another.

I found a solution but when I tried to applied to my project was not working: here in the link all the details. cloud anyone help me with that

https://github.com/dherault/serverless-offline/issues/1005#issue-632401297

Tindall answered 6/6, 2020 at 13:11 Comment(0)
H
0

there are three possible solutions.

  1. Make sure that the lambda_A have the same port and host where the lambda_B is running.

Lambda_A:

const { Lambda } = require('aws-sdk');

const lambda = new Lambda({
  region: 'us-east-1',
  endpoint: 'http://localhost:3000',
});

module.exports.main = async (event, context) => {
  // invoke
}

Lambda_B: Is running on http://localhost:3000

  1. You have configured out serverless-offline in twice functions.

https://www.serverless.com/plugins/serverless-offline#usage-with-invoke

  1. Lambda_A or Lambda_B have correctly stage?. Remember to use sls offline --stage local in both functions.
Hereabouts answered 14/11, 2021 at 22:3 Comment(1)
The port used in the endpoint needs to be the value of --lambdaPort CLI option. The default is 3002.Dichromaticism

© 2022 - 2024 — McMap. All rights reserved.