Populating metadata and retrieving in custom code

Ok I solved it, I changed:

metadata = request.json.get("metadata")

and it works