Hi @Rashid, Mubashir,
Per my research, you might using edit permission in the request. The edit includes permissions that enable users to add, edit, and delete lists; can view, add, update, and delete list items and documents. So you could upload files to sharepoint but if you want to create a new folder, you will get UnAuthorized error. To create a new folder, you will need Contribute permission level at least.
Please refer to following document
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.