Normally, I would just await .post(request_body) and the mail would be sent, but I have a synchronous Django project, so I cannot. The code above does not work.
Where you pass the function to async_to_sync and not the output from the function call - which is what would happen with async_to_sync(some_function(arg_1, arg_2))
So in other words, you probably want to do something like this: post_func = self.client.users.by_user_id(user_id).send_mail.post sync_get_data = async_to_sync(post_func)(request_body)
However, to fully answer this, we’d probably need to know what all these objects and methods are that are being called to understand what context in which they are being run.
It would also be helpful if we saw the complete error message with traceback - it’s likely to help identify where the mismatch is happening.