Filip Huhta
Filip Huhta

Reputation: 2388

Get file path from list recent files using Microsoft graph API

I'm new to Microsoft graph API where I query:

GET /me/drive/recent

List recent files

But I have just one problem with the JSON response. The attribute: "webDavUrl" returns an encoded string with the file path.

Example of the attribute "webDavUrl" with the encoded value:

 "webUrl": sitename/Documents/Microsoft%20Teams%20Chat%20Files/Inla%CC%88mningsuppgift%20-%20test%20test.pdf",

Is it possible to return a file path in the list of recent files without the encoding in Microsoft graph API or do I need to decode the string myself?

Upvotes: 0

Views: 263

Answers (1)

user2250152
user2250152

Reputation: 20768

Graph API returns only encoded url and you have to decode it by yourself.

In JS it should be simple by calling decodeURI() function.

const encodedUrl = 'sitename/Documents/Microsoft%20Teams%20Chat%20Files/Inla%CC%88mningsuppgift%20-%20test%20test.pdf';

// decode complete URL
const url = decodeURI(encodedUrl);

Upvotes: 1

Related Questions