Forum Discussion

Andrej730's avatar
Andrej730
Copper Contributor
May 10, 2020

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

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 https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createlink?view=odsp-graph-online with type = "embed". I receive an url in format "https://onedrive.live.com/embed?resid=abcdef&authkey=123456" that leads to non-working page:

 

 

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

  • Andrej730's avatar
    Andrej730
    Copper Contributor

    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 https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_thumbnails?view=odsp-graph-online.

    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).


     

     

Resources