404 response because of wrong API URL generated by onedrive.js

Copper Contributor

Hi everyone,

 

I got an issue with your OneDrive File Picker Javascript SDK (i'm using 7.2), when i use the share or download actions (it works with the query actions), OneDrive.js generate wrong API URL, mysteriously, your Javascript append to the API url the sharepoint site name.

 

Here is more details of what i do and to reproduce :

 

Like specified in your documentation (https://docs.microsoft.com/en-us/onedrive/developer/controls/file-pickers/js-v72/open-file?view=odsp...), we can pass in endpointHint a SharePoint document library URL.
So i've set the URL to my shared documents sharepoint website, i'm under a french sharepoint so url is https://mytenant.sharepoint.com/Documents%20partages/ instead of https://mytenant.sharepoint.com/shared%20documents/.

 

Everything ok, popup, then login, then the onedrive picking page:

 

97581212-9526e180-19f4-11eb-975e-2a5185c1029f.png

 

I select one or several files, then click on "Ouvrir" (Open), popup close and then i got 404 error response with this error :

XHR GET https://mytenant.sharepoint.com/Documents%20partages/_api/v2.0/drives/b!SACSU4CwMEumL8i7GhBy_6-tGhuvB9VBhv2zaXnTBlwJEM203M0NRb0Nrb5cytGZ/items/01YGYIIS7WVLP4SNN4CNBLPC7ZUWSJ4ZJW
[HTTP/2 404 Not Found 68ms]
XHR GET https://mytenant.sharepoint.com/Documents%20partages/_api/v2.0/drives/b!SACSU4CwMEumL8i7GhBy_6-tGhuvB9VBhv2zaXnTBlwJEM203M0NRb0Nrb5cytGZ/items/01YGYIIS37VMXCKXOYE5FKUSIBZF42OTDH
[HTTP/2 404 Not Found 65ms]
[OneDriveSDK] calling xhr failure callback, status: 404 
OneDrive.js:4:42959
[OneDriveSDK] Received ajax error. 
OneDrive.js:4:42959
[OneDriveSDK] Failed due to unknown error:  
OneDrive.js:4:42959
TypeError: a is undefined
    shareItems https://js.live.net/v7.2/OneDrive.js:4
    shareItems https://js.live.net/v7.2/OneDrive.js:4
    o https://js.live.net/v7.2/OneDrive.js:12
    H https://js.live.net/v7.2/OneDrive.js:12
    A https://js.live.net/v7.2/OneDrive.js:12
    f https://js.live.net/v7.2/OneDrive.js:12

I don't know why, but OneDrive.js generates wrong API urls, instead of generating https://mytenant.sharepoint.com/_api/v2.0/drives/{driveId} it generates https://mytenant.sharepoint.com/Documents%20partages/_api/v2.0/drives/{driveId}

The subdir /Documents%20partages is appended to the URI... here is a screenshot of Firefox console :

 

97581754-3e6dd780-19f5-11eb-98e7-3718ab4bb829.png

Here is my snippet:

let odOptions = {
                clientId: appId,
                action: "share",
                multiSelect: true,
                advanced: {
                    endpointHint: 'https://mytenant.sharepoint.com/Documents%20partages/',
                    createLinkParameters: { type: "edit", scope: "organization" },
                    redirectUri: Routing.generate('onedrive_redirect', null, true),
                },
                success: function(files) {
                    console.log(files);
                },
                cancel: function() {
                    console.log('cancel');
                },
                error: function(error) {
                    console.log(error);
                }
            }
            OneDrive.open(odOptions);

Here is the SDK version i used:

https://js.live.net/v7.2/OneDrive.js

 

PS : i've replaced my real tenant name instead of mytenant

 

 

1 Reply

Can someone help me on this? Don't have any news also on Github. Issue still here. Thanks.