OneDrive API - createLink with type "embed" returns dead urls

%3CLINGO-SUB%20id%3D%22lingo-sub-1377613%22%20slang%3D%22en-US%22%3EOneDrive%20API%20-%20createLink%20with%20type%20%22embed%22%20returns%20dead%20urls%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1377613%22%20slang%3D%22en-US%22%3E%3CP%3EHello.%20I've%20just%20started%20using%20OneDrive%20Rest%20API%20(I'm%20using%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FOneDrive%2Fonedrive-sdk-python%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FOneDrive%2Fonedrive-sdk-python%3C%2FA%3E%20if%20that's%20important).%20What%20I'm%20trying%20to%20accomplish%20is%20to%20get%20embed%20url%20for%20some%20pictures%20from%20OneDrive.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20get%20an%20error%20while%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fonedrive%2Fdeveloper%2Frest-api%2Fapi%2Fdriveitem_createlink%3Fview%3Dodsp-graph-online%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EcreateLink%20method%3C%2FA%3E%20with%20type%20%3D%20%22embed%22.%20I%20receive%20an%20url%20in%20format%20%22%3CA%20href%3D%22https%3A%2F%2Fonedrive.live.com%2Fembed%3Fresid%3Dabcdef%26amp%3Bauthkey%3D123456%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fonedrive.live.com%2Fembed%3Fresid%3Dabcdef%26amp%3Bauthkey%3D123456%3C%2FA%3E%22%20that%20leads%20to%20non-working%20page%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5.png%22%20style%3D%22width%3A%20782px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F190423i98BCAA2938B5994D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5.png%22%20alt%3D%22%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20try%20to%20get%20link%20from%20onedrive%20website%20interface%20(using%20%22Embed%22%20option)%20it%20works%20fine%20but%20it's%20in%20different%20format%20(%3CA%20href%3D%22https%3A%2F%2Fyfzapq.am.files.1drv.com%2Fabcdefg123456%3Fheight%3D504%26amp%3Bwidth%3D504%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fyfzapq.am.files.1drv.com%2Fabcdefg123456%3Fheight%3D504%26amp%3Bwidth%3D504%3C%2FA%3E).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAm%20I%20missing%20something%3F%20Is%20there%20way%20to%20get%20working%20embed%20urls%20via%20OneDrive%20API%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPS%20I've%20found%20that%20some%20people%20also%20receiving%20the%20same%20issue%20-%20%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F58805214%2Fonedrive-rest-api-embed-download-url%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F58805214%2Fonedrive-rest-api-embed-download-url%3C%2FA%3E%3C%2FP%3E%3CP%3EWhat%20I've%20also%20found%20that%20in%202016%20ember%20urls%20were%20unavailable%20in%20API%20(%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FOneDrive%2Fonedrive-api-docs%2Fissues%2F102%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FOneDrive%2Fonedrive-api-docs%2Fissues%2F102%3C%2FA%3E).%20Maybe%20nothing%20changed%20since%20then.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1377613%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAPI%20REST%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOneDrive%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Epython%20sdk%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1493271%22%20slang%3D%22en-US%22%3ERe%3A%20OneDrive%20API%20-%20createLink%20with%20type%20%22embed%22%20returns%20dead%20urls%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1493271%22%20slang%3D%22en-US%22%3E%3CP%3EFigured%20the%20solution%3A%3C%2FP%3E%3CDIV%20class%3D%22answercell%20post-layout--right%22%3E%3CDIV%20class%3D%22post-text%22%3E%3CDIV%20class%3D%22votecell%20post-layout--left%22%3E%3CDIV%20class%3D%22js-voting-container%20grid%20fd-column%20ai-stretch%20gs4%20fc-black-200%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%20class%3D%22answercell%20post-layout--right%22%3E%3CDIV%20class%3D%22post-text%22%3E%3CP%3EI've%20looked%20up%20how%20exactly%20onedrive%20is%20getting%20embed%20url%20when%20you%20use%20%22Embed%22%20on%20website.%20Turned%20out%20it%20uses%20other%20function%20than%20createLink%20-%20it%20uses%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fonedrive%2Fdeveloper%2Frest-api%2Fapi%2Fdriveitem_list_thumbnails%3Fview%3Dodsp-graph-online%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%2Fthumbnails%3C%2FA%3E.%3C%2FP%3E%3CP%3EAnd%20you%20can%20also%20use%20this%20function%20as%20it%20is%20a%20part%20of%20Rest%20API%20-%20as%20result%20you'll%20get%20links%20in%20format%20%3CA%20href%3D%22https%3A%2F%2Fyfzapq.am.files.1drv.com%2Fabcdefg123456%3Fwidth%3D768%26amp%3Bheight%3D1024%26amp%3Bcropmode%3Dnonethat%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fyfzapq.am.files.1drv.com%2Fabcdefg123456%3Fwidth%3D768%26amp%3Bheight%3D1024%26amp%3Bcropmode%3Dnonethat%3C%2FA%3E%20that%20seems%20to%20last%20forever.%20If%20you%20remove%20all%20the%20parameters%20from%20url%20(%3CEM%3E%3Fwidth%3D768%26amp%3Bheight%3D1024%26amp%3Bcropmode%3Dnone%3C%2FEM%3E)%20it%20will%20lead%20to%20the%20original%20image.%3C%2FP%3E%3CP%3EPS%20The%20problem%20with%20this%20method%20-%20thumbnail%20urls%20are%20dying%20within%204%20hours%20(from%20my%20experience).%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello. I've just started using OneDrive Rest API (I'm using https://github.com/OneDrive/onedrive-sdk-python if that's important). What I'm trying to accomplish is to get embed url for some pictures from OneDrive.

 

I get an error while using createLink method with type = "embed". I receive an url in format "https://onedrive.live.com/embed?resid=abcdef&authkey=123456" that leads to non-working page:

 

изображение.png

 

If I try to get link from onedrive website interface (using "Embed" option) it works fine but it's in different format (https://yfzapq.am.files.1drv.com/abcdefg123456?height=504&width=504).

 

Am I missing something? Is there way to get working embed urls via OneDrive API?

 

PS I've found that some people also receiving the same issue - https://stackoverflow.com/questions/58805214/onedrive-rest-api-embed-download-url

What I've also found that in 2016 ember urls were unavailable in API (https://github.com/OneDrive/onedrive-api-docs/issues/102). Maybe nothing changed since then.

1 Reply
Highlighted

Figured the solution:

 

I've looked up how exactly onedrive is getting embed url when you use "Embed" on website. Turned out it uses other function than createLink - it uses /thumbnails.

And you can also use this function as it is a part of Rest API - as result you'll get links in format https://yfzapq.am.files.1drv.com/abcdefg123456?width=768&height=1024&cropmode=nonethat that seems to last forever. If you remove all the parameters from url (?width=768&height=1024&cropmode=none) it will lead to the original image.

PS The problem with this method - thumbnail urls are dying within 4 hours (from my experience).