Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
Getting the event body attributes in Ruby with AWS Lambda

So I'm new to ruby and I have a simple REST API.

The post request looks like this:

POST /endpoint, { 'message': 1 }

My lambda handler looks like this:

def run(event:, context:)
    puts "#{event['body']}"
    # prints the request body
end

I'm trying to figure out how to store message, which is an int in a variable.

I was trying to do something like this but doesn't work

my_int = event['body']['message']
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

event['body'] is going to return a string, a json string.

You need to parse it with something like this.

body = JSON.parse(event['body'])
my_int = body['message']

Also if you were to do.

puts event.inspect

instead of

puts "#{event['body']}"

you would have been able to see that body returned a string and not an object. I hope that helps and good luck.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda