Forum Discussion
How to generate a direct download link from the shared OneDrive link
Thank you very much for your support and sharing.
I understood and realized that I needed to do 2 things below:
1. change the share link
2. update the source code to handle the new link format
about item number 2, your instructions are very detailed, thanks a lot
about item number 1, currently, on my side, it's like this:
- the link after sharing setup on OneDrive is like below:
https://1drv.ms/u/c/xxxxxxxxxxxxxxxxxxxxxx/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- then I pasted the above link into Chrome incognito mode to see how the link is returned, the result is as below:
From this result, I have seen the 'cid' and 'id', but I can't find the 'resid' anywhere.
Please tell me how to get the 'resid' information then I can create the link as you shared above below:
https://onedrive.live.com/?cid=XXXXXXX&id=XXXXXXX&resid=XXXXXXX
Best regards,
Henry Tien
Hi,
I added the information I did.
I found the 'resid' !
Step 1:
Copied the OneDrive shared link (everyone can edit) below:
https://1drv.ms/u/c/XXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Step 2:
Pasted it on Chrome Incognito, very quickly I caught the link being converted by Microsoft as below (1):
https://onedrive.live.com/?id=XXXXXXXXXXXXXXX%215818&resid=XXXXXXXXXXXXXXX%215818&cid=XXXXXXXXXXXXXXX&redeem=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&migratedtospo=true&v=validatepermission
And finally it's formatted as below (2):
https://onedrive.live.com/?redeem=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&cid=XXXXXXXXXXXXXXX&id=XXXXXXXXXXXXXXX%215818&parId=XXXXXXXXXXXXXXX%214001&o=OneUp
( compared this and found (1).resid = (2).id )
Step 3:
As your instruction, I have created the link below:
https://onedrive.live.com/?cid=XXXXXXXXXXXXXXX&id=XXXXXXXXXXXXXXX%215818&resid=XXXXXXXXXXXXXXX%215818
Step 4:
When above link went through the source code we built, the final direct link we get is:
https://api.onedrive.com/v1.0/shares/u!XXXXXXXXXXXXXXX%215818/root/content
Step 5:
Downloading by source code, and when debugging, instead of the 401 exception as before, it's now a 400 Exception (Bad Request).
Please see the image below
Best Regards,
Henry Tien
- tienitAug 10, 2024Copper Contributor
- rubendescensosSep 13, 2024Copper Contributor
tengo el mismo problema si encue tra alguien solucion que informe porfavor tienit