def get_payload_from_http_message(req):
    bytes = req.data
    if not bytes:
        return None
    if req.mimetype != "application/json":
        raise SpecError('Content-Type must be "application/json" got "%s" instead' % req.mimetype)
    charset = req.mimetype_params.get("charset", "utf-8")
    if charset.lower() != "utf-8":
        raise SpecError('Content-Type charset must be "utf-8" got %s instead' % charset)
    try:
        data = bytes.decode('utf-8')
    except __HOLE__:
        raise SpecError("Unicode Decode Error")
    try:
        return Box(json.loads(data))
    except ValueError:
        raise SpecError("Invalid JSON")
dataset/ETHPy150Open cosmic-api/cosmic.py/cosmic/http.py/get_payload_from_http_message