Hi Shivam,
I have implemented this a couple of weeks ago for a client.
I do not know if you need some form of authentication and the steps that I wrote down below are probably very specific for my setup but it may help you get in the right direction. Here are the steps that I have implemented:
Maybe I forgot something to mention so feel free to ask questions.
Some extra documentation:
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/register-sharepoint-add-ins
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom
https://medium.com/@yash_agarwal2/performing-oauth-and-rest-calls-with-sharepoint-online-without-creating-an-add-in-677e15c8d6ab
I am not sure on share point side, but you could encode you’re file document on Mendix on base64 and send it then by Rest Service in the message. Maybe you take a look in the Module Community Commons for some helpful Java actions.