0

We're building a system to migrate files and folders into and out of Sharepoint and we're trying to handle all the kinds of objects that might potentially contain files. This is proving to be difficult since there doesn't seem to be a consistent way to treat these objects.

I would like to be able to pass a string that looks like a path to a function and not have to worry if the path contained subsites, libraries, or folders.

GetFolderByServerRelativeUrl() seems to be close to what I want, but it chokes if there's a subsite in the path and it's a little lacking in metadata.

As an example say I had a site at company.sharepoint.com it has a subsite 'Marketing' and in that subsite there's a document library called 'Campaigns' and the library has a folder called '2014'.

So I'd like to make a request to a URL that looks something like this: http://company.sharepoint.com/_api/web/GetByPath('Marketing/Campaigns/2014')

The closest I can come is http://company.sharepoint.com/Marketing/_api/web/GetFolderByServerRelativeUrl('Campaigns/2014')

Which means I have to know what's a subsite and what's a folder/library and I'd really like I didn't have to check/store that metadata.

0

As far as i understand your problem you have full path of the resource and you don't need to check if its subsite, list or folder.

One thing you can do is from the full path remove the site collection url and in this way you will get relative path of the resource and use the same api as

 http://company.sharepoint.com/Marketing/_api/web/GetFolderByServerRelativeUrl('Relative Path')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.