Recent Discussions
Upload files to onedrive personal using python on non-interactive method
As part of my python project, I need to upload a file to onedrive personal folder non-interactive way. I have created an app registration in Azure provided below API permissions: Account Type: Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox) API Permissions: Python code: import requests # Replace with your details client_id = 'xxxxxx' client_secret = 'xxxxx' tenant_id = 'xxxxx' filename = 'C:/ABB_2025-01-13.csv' onedrive_folder = 'CloudOnly/test' user_id = 'c19d6ba9-e7d1-xxxxx-xxxxxx' # Get the access token url = f'https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token' data = { 'grant_type': 'client_credentials', 'client_id': client_id, 'client_secret': client_secret, 'scope': 'https://graph.microsoft.com/.default' } response = requests.post(url, data=data) token = response.json().get('access_token') # Upload the file to OneDrive headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'application/octet-stream' } file_content = open(filename, 'rb').read() upload_url = f'https://graph.microsoft.com/v1.0/users/{user_id}/drive/root:/{onedrive_folder}/{filename.split("/")[-1]}:/content' upload_response = requests.put(upload_url, headers=headers, data=file_content) if upload_response.status_code == 201: print('File uploaded successfully!') else: print('Error uploading file:', upload_response.json()) Error: Error uploading file: {'error': {'code': 'BadRequest', 'message': 'Tenant does not have a SPO license.', 'innerError': {'date': '2025-01-14T02:15:47', 'request-id': 'cf70193e-1723-44db-9f5e-xxxxxxx', 'client-request-id': 'cf70193e-1723-44db-9f5e-xxxxxxx'}}} How to resolve this ?7Views0likes0CommentsOld Onedrive storage location on External HD causing problems with Windows apps on laptop
Hi Everyone, Until a few months ago, I used to work in an organisation, where I was given an office laptop linked to a Microsoft Onedrive account ("Official Onedrive"). I had set up a personal external HD (Per-HD1") to act as a storage location for this Onedrive account. Periodically, I would connect this Per-HD1 to my personal laptop, open the Official Onedrive, and it would sync my office data to the Per-HD1 in a sub-folder called "Sync-latest". I also had a personal laptop, an HP 2009 model, where I had built up, over the years, a sizeable inventory of personal documents. Other personal documents were saved on another external HD ("Per-HD2"). And lastly, I also used to have a personal Onedrive account since many years, which I used for storing some random news cuttings, etc, consuming less than 20% of the Onedrive allowance of 5GB. A few months ago, I left that organisation. At this point, (a) my office data was saved in Per-HD1 (b) my personal data was saved partly in the 2009 laptop, partly in my Per-HD2, and partly in my personal Onedrive. As I wanted to buy a new personal laptop and trade-in my old 2009 laptop, I copy-pasted my personal data from my old 2009 laptop to Per-HD1. I then bought the new personal laptop, loaded with MS Office 2021 Home & Student Edition, Windows 11, and simultaneously traded-in the old 2009 laptop to the seller, after formatting the hard disk. I then did the following: a) CUT-PASTED my personal data from Per-HD1 to my new personal laptop's C drive under "Documents" folder b) CUT-PASTED my last office data from the "Sync-latest" sub-folder in my Per-HD1 to my new laptop's C drive under "Documents" folder. Just to re-emphasise, the "Sync-latest" sub-folder on my Per-HD1, is the external hard drive location, where I used to sync my office data from my Official Onedrive. c) created a few more Word/Excel documents in my personal Onedrive. So now, my documents are spread out as follows: Some are in my personal Onedrive Some others are in my C drive under "Documents" Some others are in my Per-HD2 My Per-HD1, which does not contain any of my useful or relevant documents any more, but which is the source of the problem, now looks as shown below: CANNOT PUBLISH THE SCREENSHOT, LET ME KNOW HOW TO, SO THAT YOU GET A CLEARER IDEA OF THE PROBLEM The three folders shown in the red box above, have the following contents: 1. The "Sync-latest" folder has the following two (lowest level) sub-folders: (a) "Desktop" as shown below - which contains shortcuts to some personal documents (not from my old employment) which are located either in my personal onedrive, or in my Per-HD2, and whose shortcuts I created and sent them to the desktop of my personal laptop. CANNOT PUBLISH THE SCREENSHOT, LET ME KNOW HOW TO, SO THAT YOU GET A CLEARER IDEA OF THE PROBLEM and (b) "Screenshots" as shown below - which contains the screenshots that have been copy-pasted on this page, as shown below: CANNOT PUBLISH THE SCREENSHOT, LET ME KNOW HOW TO, SO THAT YOU GET A CLEARER IDEA OF THE PROBLEM As you can see, the "Sync-latest" folder on my Per-HD1, which used to earlier contain my synced office data from my Official Onedrive, and from where I had cut-pasted all my office data to my personal laptop's "Documents" folder, is still somehow "active" and contains the shortcuts that were created on my personal laptop (how??), as well as screenshots that I take from the screen snipper application on my personal laptop (how??) !!!! 2. The "OLD BACKUPS" folder contains my superceded office data 3. The "OneDrive Temp" folder looks as shown in the screenshot below: CANNOT PUBLISH THE SCREENSHOT, LET ME KNOW HOW TO, SO THAT YOU GET A CLEARER IDEA OF THE PROBLEM I noted that the above strangely numbered sub-folders were created at the time of the last syncing of my office data with Per-HD1 on the dates indicated. I recall running into some sync issues back then, but then was able to somehow (no idea how) ensure that all my office data was properly synced and available on Per-HD1, before I returned the office laptop. I have noted that deleting these sub-folders causes some unexpected problems, so restored them back from the Recycle Bin. So the PROBLEMS which require an urgent resolution are: 1. If I do not connect Per-HD1 to my personal laptop before starting it, OR if I delete the "Sync-latest" folder in Per-HD1, two major things happen: (i) each and every app on the home screen as shown in the screenshot below (in red boxes) disappears, but if I shut down the laptop, reconnect PerHD1, and then restart the laptop, these apps re-appear on the desktop and taskbar. CANNOT PUBLISH THE SCREENSHOT, LET ME KNOW HOW TO, SO THAT YOU GET A CLEARER IDEA OF THE PROBLEM (ii) none of the documents using MS office (Word, Excel, PPT, etc) can be opened, regardless of where they are stored - C drive, PerHD2, or personal Onedrive. NB: Non-MS Office documents, eg. PDF, wherever stored, can however be opened 2. If I delete the "OneDrive Temp" folder, some problem happens, whose details I have forgotten, and do not want to re-create the problem for fear of losing access to my data. In sum, as you can see, it looks like Per-HD1 has somehow got a "stranglehold" on my personal laptop, due to the fact that it used to be my Official Onedrive sync location. I need to, without losing any data, delink Per-HD1 from my personal laptop, otherwise I will have to forever carry Per-HD1 around with my laptop wherever I go. Just in case it is relevant to the issue, I had delinked my official Onedrive account from my new personal laptop, before giving my office laptop back to the organisation. And I had also delinked my old 2009 laptop from my personal Onedrive account. So now, my personal Onedrive account is linked only to my new personal laptop.8Views0likes0CommentsOpening OneDrive files from Finder on Mac does not enable Autosave like on Windows.
Hello all. I am having an issue with using OneDrive on Mac. If I open a file, say a Word doc or PowerPoint, on OneDrive through Finder, the Autosave feature will not be on by default. If I do the same action on Windows through file explorer, it opens with Autosave turned on. When I try to turn on Autosave in Word, it prompts me to upload a new version onto OneDrive. This would make a new copy. And that new copy, if opened from Finder, still will not have autosave turned on. However, when I open the file from within the Word application or Excel or PowerPoint, autosave is turned on automatically. I would like for files opened from my OneDrive folder in Finder to open with Autosave turned on by default. This is how it works on Windows.101Views0likes1CommentOneDrive is forcing users to login to upload content
All the settings appear to be correct so what is going on? As soon as they click the upload button they are forced to login and they don't have an MS account. This is not a cachine issue as I've tested it in EDGE with my gmail account and I never use edge This is for simply sharing a folder to others to contribute too.12Views0likes0CommentsOnedrive is asking users to sign in to upload
I have setup the proper security so I'm super confused on why an external user, non m365 is required to sign in to upload a file. After I setup the blow settings I share the link from the Copy Link button. it's not a caching issue. It's happening for me in edge which i never use and other users devices4Views0likes0CommentsHow to generate a direct download link from the shared OneDrive link
Dear Experts and Supporters I'm a developer working on an issue related to downloading files from OneDrive. Everything was running fine until a few days ago when I reopened my app Here are my lines // shared OneDrive link example // https://1drv.ms/u/s!Atj71Lw5QEdsrQnTRHMj-fjGc49N?e=hOB5gO if (string.IsNullOrWhiteSpace(sharingURL)) return string.Empty; var base64Value = Convert.ToBase64String(Encoding.UTF8.GetBytes(sharingURL)); var encodedUrl = "u!" + base64Value.TrimEnd('=').Replace('/', '_').Replace('+', '-'); var directlyUrl = $"https://api.onedrive.com/v1.0/shares/{encodedUrl}/root/content"; And now when I cannot download from OneDrive, I have debugged and realized that there was a 401 Unauthorized exception But the file has been shared for Everyone with Edit permissions. I thought Microsoft had changed something about the shared link recently and the current way to get the direct download link as it is now is not possible. The shared link I see it's longer than before and different in format (no s!, no ?e=) So please kindly help me to solve this case. Thanks in advance! Henry Tien (email address removed for privacy reasons)2.1KViews2likes7CommentsNo way of running OneDrive on Windows Server 2019?
I'm running an instance of Windows Server 2019 on Amazon AWS, and need to sync some files. ApparentlyWindows Server 2019 comes with no traces of OneDrive (even though the OneDrive webpage recognizes my web client as Windows 10 and assures me that it should be installed), so I'm trying to install the app manually. I've downloaded OneDriveSetup.exe (from onedrive.live.com), but the system ignores it when I try to run it, ie. nothing happens... I'm close to tear out my hair, what is happening?Solved116KViews0likes15CommentsCopilot prompts answers in word document in OneDrive
Hello I think I made a mistake tonight, I am discussing and learning a lot with Copilot and I don't have good memory. A while ago I started using Microsoft 365 and OneDrive to document some info because I use it for reference. I never had any problems before tonight. I was just playing with my last document in word. I then got a signal and a link to the Microsoft security hub. I did not have any bad intentions, did and do not plan to distribute or sell. The terms of use contract stipulates that we can use the resources for personal use. Hope to touch base Thank you31Views0likes0CommentsWhy are all the files I copy in OneDrive only in OneDrive ?
Hi. I recently copy all my documents in OnDrive for save, because I am writting my PhD thesis and want some saves. The problem is that I wanted to keep my files in normal files, on my computer, and have a copy in One Drive. But now, each and every files that I copy are only in OneDrive. Each files of my computer are now sync with OneDrive. But I want to keep files on my computer and copy them in OneDrive only when I want to, not automatically because now I don't have any normal files on my computer. How can I repair this ? Thank you in advance,120Views0likes1CommentStop "Backup this document" prompt in Office
Every so often when I open a file in Excel or Word (perhaps about one in five), I get a prompt that says "Backup this document to OneDrive". I use Windows11 and Office365. I have every option for OneDrive backup turned off. I have it set for all files stored locally, all folders are off for backup in OneDrive settings. Anytime OneDrive asks me to back something up I dismiss it. How can I turn this nagging prompt off permanently?17Views0likes0CommentsSharing photos in One drive with Samsung user
Help! Have family 365 account and have set up a file of thousands of family photos. In the past no problem. Sent to their email and then they could access the file with all the photos coming up and viewed online. They have a Samsung phone. Now the link is there to the file but each photo needs to be downloaded separately. Any ideas how to resolve?25Views0likes2CommentsOneDrive direct download link
Hi, We have tried to get direct download link or to access publicly shared drive file with Graph API . It seems that the the URL structure has changed as well as the API. The thing behind the API is that i cant access file though https://graph.microsoft.com/v1.0/shares/{sharedDriveItem-id} this endpoint since when i get the link and try to encode it to get sharedDriveItem-id the response is that the "The sharing link no longer exists, or you do not have permission to access it.". Anyone has any idea how to get direct download URL from initial public share URL give by someone? Thank you.64Views0likes0CommentsModification loss in excel files hosted on OneDrive
On December 4th I discovered losses of modifications in some files. When opening an Excel file I often work with, I was suprised since I was sure I added some lines into it a few days ago. I looked at version history and found a strange behaviour on December 4th: several versions on 29th November 15:06 with the same size. One of the 3 versions of 29th November 15:06 seem to be the latest in terms of modifications, even the size was similar. So I manually recovered this one. I did the same on a 2nd excel file to confirm the issue. Other files may be impacted. How can that happen? Could it be a ntp issue leading OneDrive not to know which version is the latest? I opened a case at MS support, but they closed the case w/o resolution. They even didn't try to understand the issue, just sending a TN how to restore a version of a file. But first I need to identify all the impacted files, then to find the correct version. I can't do these actions manually on hundred or maybe thousands of files. How could I proceed? Do u think it is related to Excel or OneDrive or to sthg else?64Views0likes2CommentsPhoto comments not backup to OneDrive
I frequently add comments/descriptions to the pictures in my Android and iPhone, however after spending a few nights backing up my albums, I found out only the photo files are uploaded and no comments are included. Is there a way to upload with comments or is that a limitation of OneDrive?48Views0likes1CommentOneDrive Windows 11 App Synch Problem
Hello, My OneDrive synchronization app for Windows 11 no longer synchronizes, it gets stuck at a finished download (26.9GB of 26.9GB at 0.0 Kb/s) and does not continue. An upload didn't work (anymore) either, I cleared or moved the storage space, but nothing happened in the app. I have logged into the app again and everything has to be synchronized, but as I said, it is now stuck during the download. I have read and tried a lot on the Internet, such as the reset, which somehow sometimes works temporarily but on the whole only takes time with the amount of data, is there no easier reset or cache clearing option? or is my plan with the sharing of folders from 2 family subscriptions and 11 Microsoft accounts on 1 main account for up to 12 TB of data simply too much? MFG ----------------------------------------- German Version: Hallo, Meine OneDrive Synchronisations App für Windows 11 Synchronisiert nicht mehr, er bleibt bei einem fertigen Download (26.9GB von 26.9GB bei 0,0 Kb/s) hängen und macht nicht mehr weiter. Ein Upload hat ursprünglich auch nicht (mehr) geklapptn, Ich habe den Speicherplatz zwar freigeräumt bzw. verschoben, aber es passierte in der App nichts. Ich habe mich erneut in der App angemeldet und es muss alles synchronisiert werden, bleibt aber wie gesagt jetzt bei dem Download hängen. Im Internet habe ich viel dazu gelesen und probiert wie z.b. der reset, was zwar irgendwie manchmal zeitweilig funktioniert aber im großen und ganzen auch nur Zeit bei der Menge der Daten schindet, Gibt es keine einfachere Reset oder Cache leeren möglichkeit? oder ist mein Plan mit dem Teilen von Ordnern von 2 Familien Abos und 11 Microsoft Accounts auf 1 Haupt Account für bis zu 12 TB Daten schlicht zuviel ? MFG57Views0likes1Commentpersonal account can't search files
hello,recently I found that personal account can't search files by GET /me/drive/root/search(q='{search-text}') . I am sure the target file exist in OneDrive. I can access it by GET /me/drive/root/children.is anyone know why and how can I solve it? here are my personal account testing result screenshot: the folder named "Documents" is exist. and the search result is a empty array also, here are communications records in Microsoft Q&A: https://learn.microsoft.com/zh-cn/answers/questions/2133894/onedrive-rest-api78Views0likes0Comments".tmp.driveupload"
I am having an issue where my word doc (set to autosave to OneDrive business desktop app) on my PC is suddenly saved in a ".tmp.driveupload" folder online under a different file name (random numbers), with autosave switched off. If I do not notice this happening, the change to the document is not saved under the expected folder and file name, resulting in no change made to the file I opened. The only workaround I've found is to "save a copy" and overwrite the file I opened in the original folder. This only works if I notice the sudden name change and file save in the tmp folder. If I don't, the changes are lost because the tmp file is deleted (to recycle bin) on exit and the tmp folder is not synced to my PC. I have to go online to the OneDrive business website, guess which file it may be, restore that from the OneDrive recycle bin, and hope it is the file I was looking for. The frequency of this happening means that there are numerous tmp files under pseudo file names to scour through. One-hour plus on the phone with MS Office subscription support is of no help.2.8KViews1like6Comments
Events
Recent Blogs
- 9 MIN READAt today’s OneDrive , we unveiled a powerful lineup of new features designed to help you work smarter, stay organized, and relive life’s best moments-Let’s take a closer look at what’s new!Jan 14, 202588KViews16likes31Comments
- 2 MIN READAre you ready to connect with OneDrive product makers this month? We’re gearing up for the next call. Are you ready to connect with OneDrive product makers this month? We’re gearing up for the ne...Jan 13, 2025340Views0likes1Comment