HTTP endpoint decrator not workin gin Anvil App Server (Self-Hosted)

I am trying to POST this payload…

curl -X POST http://localhost:3030/_/api/s3/crucis-tours \
  -H "Content-Type: application/json" \
  -d '{
    "subject": "Failing to get data from lambda",
    "from_addr": "Test User <test@email.com>",
    "to": "Inbound <inbound@anvil.app>",
    "text_body": "We will get there!!",
    "attachments": []
  }' 

to back-end http_endpoint decorator as follows:

@anvil.server.http_endpoint("/s3/crucis-tours", methods=["POST"])
def handle_incoming_emails(**msg):
  return msg

However, all that is returned is…
{}

Why is the payload arriving empty?

You’re passing your data in the body as JSON. I think what you want is anvil.server.request.body_json.

Yes , that worked. Thanks.

1 Like